Documentation ¶
Overview ¶
Package user is the result of users and clients ended up having to be split apart after all, once adding the SQL backing started falling into place. Users are very similar to clients, except that they are unique across the whole server and can log in via the web interface, while clients are only unique across an organization and cannot log in over the web. Basically, users are generally for something you would do, while a client would be associated with a specific node.
Note: At this time, organizations are not implemented, so the difference between clients and users is a little less stark.
Index ¶
- func ExportAllUsers() []interface{}
- func GetList() []string
- func ValidatePublicKey(publicKey interface{}) (bool, util.Gerror)
- type User
- func (u *User) CheckPasswd(password string) util.Gerror
- func (u *User) CheckPermEdit(userData map[string]interface{}, perm string) util.Gerror
- func (u *User) Delete() util.Gerror
- func (u *User) GenerateKeys() (string, error)
- func (u *User) GetName() string
- func (u *User) GobDecode(b []byte) error
- func (u *User) GobEncode() ([]byte, error)
- func (u *User) IsAdmin() bool
- func (u *User) IsClient() bool
- func (u *User) IsSelf(other interface{}) bool
- func (u *User) IsUser() bool
- func (u *User) IsValidator() bool
- func (u *User) Passwd() string
- func (u *User) PublicKey() string
- func (u *User) Rename(newName string) util.Gerror
- func (u *User) Save() util.Gerror
- func (u *User) SetPasswd(password string) util.Gerror
- func (u *User) SetPasswdHash(pwhash string)
- func (u *User) SetPublicKey(pk interface{}) error
- func (u *User) ToJSON() map[string]interface{}
- func (u *User) URLType() string
- func (u *User) UpdateFromJSON(jsonUser map[string]interface{}) util.Gerror
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportAllUsers ¶ added in v0.5.2
func ExportAllUsers() []interface{}
ExportAllUsers return all users, in a fashion suitable for exporting.
func ValidatePublicKey ¶
ValidatePublicKey checks that the provided public key is valid. Wrapper around chefcrypto.ValidatePublicKey(), but with a different error type.
Types ¶
type User ¶
type User struct { Username string `json:"username"` Name string `json:"name"` Email string `json:"email"` Admin bool `json:"admin"` // contains filtered or unexported fields }
User is, uh, a user. It's very similar to a Client, but subtly different, as explained elsewhere.
func AllUsers ¶ added in v0.5.2
func AllUsers() []*User
AllUsers returns all the users on this server.
func NewFromJSON ¶ added in v0.6.0
NewFromJSON builds a new user from a JSON object.
func (*User) CheckPasswd ¶
CheckPasswd checks the provided password to see if it matches the stored password hash.
func (*User) CheckPermEdit ¶
CheckPermEdit checks to see if the user is trying to edit admin and validator attributes, and if it has permissions to do so.
func (*User) Delete ¶
Delete a user, but will refuse to do so and give an error if it is the last administrator user.
func (*User) GenerateKeys ¶
GenerateKeys generates a new set of RSA keys for the user. The new private key is saved with the user object, the public key is given to the user and not saved on the server at all.
func (*User) IsAdmin ¶
IsAdmin returns true if the user is an admin. If use-auth is false, this always returns true.
func (*User) IsSelf ¶
IsSelf returns true if the actor in question s the same client or user as the caller. Always returns true if use-auth is false.
func (*User) IsValidator ¶
IsValidator always returns false, since users are never validators. This is true even if auth mode is not on.
func (*User) Passwd ¶ added in v0.11.1
Passwd returns the password hash, either from the user object or an external secret store
func (*User) Rename ¶
Rename a user. Save() must be called after this method is used. Will not rename the last administrator user.
func (*User) SetPasswd ¶
SetPasswd validates and sets the user's password. Will not set a password for a client.
func (*User) SetPasswdHash ¶ added in v0.5.2
SetPasswdHash is a utility function to directly set a password hash. Only especially useful when importing user data with the -m/--import flags, since it's still hashed with the user's salt.
func (*User) SetPublicKey ¶
SetPublicKey does what it says on the tin. Part of the Actor interface.
func (*User) ToJSON ¶ added in v0.6.0
ToJSON converts the user to a JSON object, massaging it as needed to keep the chef client happy (be it knife, chef-pedant, etc.) NOTE: There may be a more idiomatic way to do this.