Documentation

Index

Constants

View Source
const (
	// DS is the location of the token datastore
	DS = "core" + string(os.PathSeparator) + "token.ds"
)

Variables

View Source
var ErrTokenLevel = errors.New("Token grants permissions that the requester does not currently have.")

    ErrTokenLevel is when a token is created that grants more permissions than the requester has

    Functions

    func Delete

    func Delete(u *user.User, id string) error

      Delete deletes a token

      Types

      type Token

      type Token struct {
      	Token      string `json:"token,omitempty"` // Unique identifier used for authentication
      	ID         string `json:"id,omitempty"`    //Unique identifier used for identification
      	Name       string `json:"name,omitempty"`
      	Expires    string `json:"expires,omitempty"`
      	Resource   string `json:"resource,omitempty"`
      	Permission string `json:"permission,omitempty"`
      	Created    string `json:"created,omitempty"`
      	// contains filtered or unexported fields
      }

        Token grants access to everything a user can access, or access just to a specific resource and permissions level

        func All

        func All(u *user.User) ([]*Token, error)

          All retrieves all tokens for the user

          func Get

          func Get(u *user.User, id string) (*Token, error)

            Get retrieves a token based on the passed in ID and user

            func Login

            func Login(u *user.User, tkn string) (*Token, error)

              Login attempts to login with the given token

              func New

              func New(t *Token, requester *user.User) (*Token, error)

                New creates a new token

                func (*Token) GetPermission

                func (t *Token) GetPermission(res permission.Permitter) (*permission.Permission, error)

                  GetPermission creates the permissions to check against based on the token. token access is unauthenticated in that the token doesn't have a *user.User if a permission and / or a resource is supplied so SetPermissions sets the appropriate public permissions based on token

                  func (*Token) IsExpired

                  func (t *Token) IsExpired() bool

                    IsExpired is whether or not the given token is expired

                    func (*Token) User

                    func (t *Token) User() *user.User

                      User returns the user this token is granting permissions as but only if the token doesn't grant specific resource or permissions access Tokens without resource or permissions specified allow the token user to fully emulate the user's access

                      Source Files