Documentation
¶
Index ¶
- Variables
- func BaseTokenPermission(t Token) ([]permission.Permission, error)
- func ChangeQuota(user *User, limit int) error
- func CreateTeam(name string, user *User) error
- func GetTeamsNames(teams []Team) []string
- func ParseToken(header string) (string, error)
- func RegisterScheme(name string, scheme Scheme)
- func ReleaseApp(user *User) error
- func RemoveRoleFromAllUsers(roleName string) error
- func RemoveTeam(teamName string) error
- func ReserveApp(user *User) error
- func UnregisterScheme(name string)
- type APIToken
- type AuthenticationFailure
- type ErrTeamStillUsed
- type ManagedScheme
- type RoleInstance
- type Scheme
- type SchemeInfo
- type Team
- type Token
- type User
- func (u *User) AddKey(key repository.Key, force bool) error
- func (u *User) AddRole(roleName string, contextValue string) error
- func (u *User) AddRolesForEvent(roleEvent *permission.RoleEvent, contextValue string) error
- func (u *User) Create() error
- func (u *User) Delete() error
- func (u *User) ListKeys() (map[string]string, error)
- func (u *User) Permissions() ([]permission.Permission, error)
- func (u *User) RegenerateAPIKey() (string, error)
- func (u *User) RemoveKey(key repository.Key) error
- func (u *User) RemoveRole(roleName string, contextValue string) error
- func (u *User) ShowAPIKey() (string, error)
- func (u *User) Update() error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidTeamName = errors.New("invalid team name") ErrTeamAlreadyExists = errors.New("team already exists") ErrTeamNotFound = errors.New("team not found") )
var ( ErrUserNotFound = stderrors.New("user not found") ErrInvalidKey = stderrors.New("invalid key") ErrKeyDisabled = stderrors.New("key management is disabled") )
var ErrInvalidToken = errors.New("Invalid token")
Functions ¶
func BaseTokenPermission ¶
func BaseTokenPermission(t Token) ([]permission.Permission, error)
func ChangeQuota ¶
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 CreateTeam ¶
CreateTeam creates a team and add users to this team.
func GetTeamsNames ¶
GetTeamsNames find teams by a list of team names.
func ParseToken ¶
ParseToken extracts token from a header: 'type token' or 'token'
func RegisterScheme ¶
func ReleaseApp ¶
ReleaseApp releases an app from the user list, releasing the quota spot for another app.
func RemoveRoleFromAllUsers ¶
func RemoveTeam ¶
func ReserveApp ¶
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 UnregisterScheme ¶
func UnregisterScheme(name string)
Types ¶
type APIToken ¶
type APIToken struct {
Token string `json:"token" bson:"apikey"`
UserEmail string `json:"email" bson:"email"`
}
func (*APIToken) GetAppName ¶
func (*APIToken) GetUserName ¶
func (*APIToken) IsAppToken ¶
func (*APIToken) Permissions ¶
func (t *APIToken) Permissions() ([]permission.Permission, error)
type AuthenticationFailure ¶
type AuthenticationFailure struct {
Message string
}
func (AuthenticationFailure) Error ¶
func (a AuthenticationFailure) Error() string
type ErrTeamStillUsed ¶
func (*ErrTeamStillUsed) Error ¶
func (e *ErrTeamStillUsed) Error() string
type ManagedScheme ¶
type RoleInstance ¶
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
}
type SchemeInfo ¶
type SchemeInfo map[string]interface{}
type Team ¶
Team represents a real world team, a team has one creating user and a name.
func (*Team) AllowedApps ¶
AllowedApps returns the apps that the team has access.
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 []RoleInstance `bson:",omitempty"`
}
func GetUserByEmail ¶
func ListUsersWithPermissions ¶
func ListUsersWithPermissions(wantedPerms ...permission.Permission) ([]User, error)
func ListUsersWithRole ¶
func (*User) AddRolesForEvent ¶
func (u *User) AddRolesForEvent(roleEvent *permission.RoleEvent, contextValue string) error
func (*User) Permissions ¶
func (u *User) Permissions() ([]permission.Permission, error)