auth

package
v0.0.0-...-9f1a7a8 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidToken = errors.New("Invalid token")

Functions

func BaseTokenPermission

func BaseTokenPermission(t Token) ([]permission.Permission, error)

func ChangeQuota

func ChangeQuota(user *User, limit int) error

ChangeQuota redefines the limit of the user. The new limit must be bigger than or equal to the current number of apps of the user. The new limit maybe smaller than 0, which mean that the user should have an unlimited number of apps.

func ParseToken

func ParseToken(header string) (string, error)

ParseToken extracts token from a header: 'type token' or 'token'

func RegisterScheme

func RegisterScheme(name string, scheme Scheme)

func ReleaseApp

func ReleaseApp(user *User) error

ReleaseApp releases an app from the user list, releasing the quota spot for another app.

func RemoveRoleFromAllUsers

func RemoveRoleFromAllUsers(roleName string) error

func ReserveApp

func ReserveApp(user *User) error

ReserveApp reserves an app for the user, reserving it in the database. It's used to reserve the app in the user quota, returning an error when there isn't any space available.

func TeamService

func TeamService() authTypes.TeamService

func UnregisterScheme

func UnregisterScheme(name string)

func UpdateRoleFromAllUsers

func UpdateRoleFromAllUsers(roleName, newRoleName, ctx, desc string) error

Types

type APIToken

type APIToken struct {
	Token     string `json:"token" bson:"apikey"`
	UserEmail string `json:"email" bson:"email"`
}

func APIAuth

func APIAuth(token string) (*APIToken, error)

func (*APIToken) GetAppName

func (t *APIToken) GetAppName() string

func (*APIToken) GetUserName

func (t *APIToken) GetUserName() string

func (*APIToken) GetValue

func (t *APIToken) GetValue() string

func (*APIToken) IsAppToken

func (t *APIToken) IsAppToken() bool

func (*APIToken) Permissions

func (t *APIToken) Permissions() ([]permission.Permission, error)

func (*APIToken) User

func (t *APIToken) User() (*User, error)

type AuthenticationFailure

type AuthenticationFailure struct {
	Message string
}

func (AuthenticationFailure) Error

func (a AuthenticationFailure) Error() string

type ManagedScheme

type ManagedScheme interface {
	Scheme
	StartPasswordReset(user *User) error
	ResetPassword(user *User, resetToken string) error
	ChangePassword(token Token, oldPassword string, newPassword string) error
}

type Scheme

type Scheme interface {
	AppLogin(appName string) (Token, error)
	AppLogout(token string) error
	Login(params map[string]string) (Token, error)
	Logout(token string) error
	Auth(token string) (Token, error)
	Info() (SchemeInfo, error)
	Name() string
	Create(user *User) (*User, error)
	Remove(user *User) error
}

func GetScheme

func GetScheme(name string) (Scheme, error)

type SchemeInfo

type SchemeInfo map[string]interface{}

type Token

type Token interface {
	GetValue() string
	GetAppName() string
	GetUserName() string
	IsAppToken() bool
	User() (*User, error)
	Permissions() ([]permission.Permission, error)
}

type User

type User struct {
	quota.Quota
	Email    string
	Password string
	APIKey   string
	Roles    []authTypes.RoleInstance `bson:",omitempty"`
}

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

func ListUsers

func ListUsers() ([]User, error)

ListUsers list all users registred in tsuru

func ListUsersWithPermissions

func ListUsersWithPermissions(wantedPerms ...permission.Permission) ([]User, error)

func ListUsersWithRole

func ListUsersWithRole(role string) ([]User, error)

func (*User) AddKey

func (u *User) AddKey(key repository.Key, force bool) error

func (*User) AddRole

func (u *User) AddRole(roleName string, contextValue string) error

func (*User) AddRolesForEvent

func (u *User) AddRolesForEvent(roleEvent *permission.RoleEvent, contextValue string) error

func (*User) Create

func (u *User) Create() error

func (*User) Delete

func (u *User) Delete() error

func (*User) ListKeys

func (u *User) ListKeys() (map[string]string, error)

func (*User) Permissions

func (u *User) Permissions() ([]permission.Permission, error)

func (*User) RegenerateAPIKey

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

func (*User) Reload

func (u *User) Reload() error

func (*User) RemoveKey

func (u *User) RemoveKey(key repository.Key) error

func (*User) RemoveRole

func (u *User) RemoveRole(roleName string, contextValue string) error

func (*User) ShowAPIKey

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

func (*User) Update

func (u *User) Update() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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