actor

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package actor in goiardi encompasses both Chef clients and users. They're basically the same thing. Clients are the more usual case, but users are used for the webui and often for general user (as opposed to node) interactions with the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetList

func GetList() []string

Returns a list of actors. Clients and users are stored together, so no user can have the same name as an existing client (and vice versa).

func ValidatePublicKey added in v0.4.0

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 Actor

type Actor struct {
	Name        string `json:"name"`
	NodeName    string `json:"node_name"`
	JsonClass   string `json:"json_class"`
	ChefType    string `json:"chef_type"`
	Validator   bool   `json:"validator"`
	Orgname     string `json:"orgname"`
	PublicKey   string `json:"public_key"`
	Admin       bool   `json:"admin"`
	Certificate string `json:"certificate"`

	Salt []byte
	// contains filtered or unexported fields
}

An actor is either a client or a user. They're very similar, with some small differences - users can never be validators, while clients don't have passwords. Generally nodes and the like will be clients, while people interacting with the goiardi server will be users.

func Get

func Get(clientname string) (*Actor, error)

Gets an actor from the data store.

func GetReqUser added in v0.4.0

func GetReqUser(clientname string) (*Actor, util.Gerror)

Gets the actor making the request. If use-auth is not on, always returns true.

func New

func New(clientname string, cheftype string) (*Actor, util.Gerror)

Creates a new actor of type `cheftype`. If it's a user, it will also create a password salt.

func NewFromJson

func NewFromJson(json_actor map[string]interface{}, cheftype string) (*Actor, util.Gerror)

Build a new client/user from a json object

func (*Actor) CheckPasswd added in v0.4.0

func (c *Actor) CheckPasswd(password string) util.Gerror

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

func (*Actor) CheckPermEdit added in v0.4.0

func (c *Actor) CheckPermEdit(client_data map[string]interface{}, perm string) util.Gerror

A check to see if the actor is trying to edit admin and validator attributes.

func (*Actor) Delete

func (c *Actor) Delete() error

Deletes a client or user, but will refuse to do so if it is the last adminstrator of that type.

func (*Actor) DocId

func (c *Actor) DocId() string

func (*Actor) Flatten

func (c *Actor) Flatten() []string

func (*Actor) GenerateKeys

func (c *Actor) GenerateKeys() (string, error)

Generate a new set of RSA keys for the client. The new private key is saved with the client, the public key is given to the client and not saved on the server at all.

func (*Actor) GetName

func (a *Actor) GetName() string

func (*Actor) GobDecode added in v0.4.0

func (c *Actor) GobDecode(b []byte) error

func (*Actor) GobEncode added in v0.4.0

func (c *Actor) GobEncode() ([]byte, error)

func (*Actor) Index

func (c *Actor) Index() string

func (*Actor) IsAdmin added in v0.4.0

func (c *Actor) IsAdmin() bool

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

func (*Actor) IsLastAdmin added in v0.4.0

func (c *Actor) IsLastAdmin() bool

Is this the last admin of its type?

func (*Actor) IsSelf added in v0.4.0

func (c *Actor) IsSelf(other *Actor) bool

Is the other actor provided the same as the caller.

func (*Actor) IsValidator added in v0.4.0

func (c *Actor) IsValidator() bool

Is the user a validator client? If use-auth is false, this always returns false. Users also always return false.

func (*Actor) Rename

func (c *Actor) Rename(new_name string) util.Gerror

Renames the client or user. Save() must be called after this method is used. Will not rename the last admin.

func (*Actor) Save

func (c *Actor) Save() error

func (*Actor) SetPasswd added in v0.4.0

func (c *Actor) SetPasswd(password string) util.Gerror

Validate and set the user's password. Will not set a password for a client.

func (*Actor) ToJson added in v0.4.0

func (c *Actor) ToJson() map[string]interface{}

Convert the client or user object into a JSON object, massaging it as needed to make chef-pedant happy.

func (*Actor) URLType

func (a *Actor) URLType() string

func (*Actor) UpdateFromJson

func (c *Actor) UpdateFromJson(json_actor map[string]interface{}, cheftype string) util.Gerror

Update a client/user from a json object. Does a bunch of validations inside rather than in the handler.

Jump to

Keyboard shortcuts

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