user

package
v0.6.0-pre1 Latest Latest
Warning

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

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

Documentation

Overview

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{}

Return all users, in a fashion suitable for exporing

func GetList

func GetList() []string

Returns a list of users.

func ValidatePublicKey

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

Checks that the provided public key is valid. Wrapper around chef_crypto.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
}

func AllUsers added in v0.5.2

func AllUsers() []*User

Return all the users on this server.

func Get

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

Gets a user.

func New

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

Create a new API user.

func NewFromJson

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

Build a new user from a JSON object.

func (*User) CheckPasswd

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

Check the provided password to see if it matches the stored password hash.

func (*User) CheckPermEdit

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

func (*User) Delete

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

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

Generate 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

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

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

func (*User) IsClient

func (u *User) IsClient() bool

func (*User) IsSelf

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

Is the actor in question the same client or user as the caller?

func (*User) IsUser

func (u *User) IsUser() bool

func (*User) IsValidator

func (u *User) IsValidator() bool

Users are never validators, so always return false. This is true even if auth mode is not on.

func (*User) PublicKey

func (u *User) PublicKey() string

Return the user's public key. Part of the Actor interface.

func (*User) Rename

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

Renames 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

Validate and set 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)

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

Set the user's public key. Part of the Actor interface.

func (*User) ToJson

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

Convert 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

func (*User) UpdateFromJson

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

Update 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