Documentation ¶
Index ¶
- Variables
- func BaseTokenPermission(t Token) ([]permission.Permission, error)
- func ChangeQuota(user *User, limit int) error
- func CheckUserAccess(teamNames []string, u *User) bool
- 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 RemoveTeam(teamName string) error
- func ReserveApp(user *User) error
- func UnregisterScheme(name string)
- type APIToken
- type AuthenticationFailure
- type ErrTeamStillUsed
- type ManagedScheme
- 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) AllowedApps() ([]string, error)
- func (u *User) Create() error
- func (u *User) Delete() error
- func (u *User) IsAdmin() bool
- 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) Teams() ([]Team, 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 CheckUserAccess ¶
CheckUserAccess verifies if the user has access to a list of teams.
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 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 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 team members (users) and a name.
func (*Team) AllowedApps ¶
AllowedApps returns the apps that the team has access.
func (*Team) ContainsUser ¶
ContainsUser checks if the team contains the user.
func (*Team) RemoveUser ¶
RemoveUser removes a user from the team.
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 (*User) AllowedApps ¶
func (*User) Permissions ¶
func (u *User) Permissions() ([]permission.Permission, error)