user

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2014 License: Apache-2.0 Imports: 11 Imported by: 0

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

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 GetList

func GetList() []string

GetList returns a list of users.

func ValidatePublicKey

func ValidatePublicKey(publicKey interface{}) (bool, util.Gerror)

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 Get

func Get(name string) (*User, util.Gerror)

Get a user.

func New

func New(name string) (*User, util.Gerror)

New creates a new API user.

func NewFromJSON added in v0.6.0

func NewFromJSON(jsonUser map[string]interface{}) (*User, util.Gerror)

NewFromJSON builds a new user from a JSON object.

func (*User) CheckPasswd

func (u *User) CheckPasswd(password string) util.Gerror

CheckPasswd checks the provided password to see if it matches the stored password hash.

func (*User) CheckPermEdit

func (u *User) CheckPermEdit(userData map[string]interface{}, perm string) util.Gerror

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

func (u *User) Delete() util.Gerror

Delete a user, but will refuse to do so and give an error if it is the last administrator user.

func (*User) GenerateKeys

func (u *User) GenerateKeys() (string, error)

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) GetName

func (u *User) GetName() string

GetName returns the user's name.

func (*User) GobDecode

func (u *User) GobDecode(b []byte) error

func (*User) GobEncode

func (u *User) GobEncode() ([]byte, error)

func (*User) IsAdmin

func (u *User) IsAdmin() bool

IsAdmin returns true if the user is an admin. If use-auth is false, this always returns true.

func (*User) IsClient

func (u *User) IsClient() bool

IsClient returns false for users.

func (*User) IsSelf

func (u *User) IsSelf(other interface{}) bool

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) IsUser

func (u *User) IsUser() bool

IsUser returns true for users.

func (*User) IsValidator

func (u *User) IsValidator() bool

IsValidator always returns false, since users are never validators. This is true even if auth mode is not on.

func (*User) PublicKey

func (u *User) PublicKey() string

PublicKey returns the user's public key. Part of the Actor interface.

func (*User) Rename

func (u *User) Rename(newName string) util.Gerror

Rename a user. Save() must be called after this method is used. Will not rename the last administrator user.

func (*User) Save

func (u *User) Save() util.Gerror

Save the user's current state.

func (*User) SetPasswd

func (u *User) SetPasswd(password string) util.Gerror

SetPasswd validates and sets the user's password. Will not set a password for a client.

func (*User) SetPasswdHash added in v0.5.2

func (u *User) SetPasswdHash(pwhash string)

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

func (u *User) SetPublicKey(pk interface{}) error

SetPublicKey does what it says on the tin. Part of the Actor interface.

func (*User) ToJSON added in v0.6.0

func (u *User) ToJSON() map[string]interface{}

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.

func (*User) URLType

func (u *User) URLType() string

URLType returns the base element of a user's URL.

func (*User) UpdateFromJSON added in v0.6.0

func (u *User) UpdateFromJSON(jsonUser map[string]interface{}) util.Gerror

UpdateFromJSON updates a user from a JSON object, carrying out a bunch of validations inside.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL