auth

package
v0.0.0-...-0cf49f2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2015 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTeamName   = errors.New("invalid team name")
	ErrTeamAlreadyExists = errors.New("team already exists")
	ErrTeamNotFound      = errors.New("team not found")
)
View Source
var (
	ErrUserNotFound = stderrors.New("user not found")
	ErrInvalidKey   = stderrors.New("invalid key")
	ErrKeyDisabled  = stderrors.New("key management is disabled")
)
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 CheckUserAccess

func CheckUserAccess(teamNames []string, u *User) bool

CheckUserAccess verifies if the user has access to a list of teams.

func CreateTeam

func CreateTeam(name string, user ...*User) error

CreateTeam creates a team and add users to this team.

func GetTeamsNames

func GetTeamsNames(teams []Team) []string

GetTeamsNames find teams by a list of team names.

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 RemoveTeam

func RemoveTeam(teamName 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 UnregisterScheme

func UnregisterScheme(name string)

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 ErrTeamStillUsed

type ErrTeamStillUsed struct {
	Apps             []string
	ServiceInstances []string
}

func (*ErrTeamStillUsed) Error

func (e *ErrTeamStillUsed) 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 Team

type Team struct {
	Name  string   `bson:"_id" json:"name"`
	Users []string `json:"users"`
}

Team represents a real world team, a team has team members (users) and a name.

func GetTeam

func GetTeam(name string) (*Team, error)

GetTeam find a team by name.

func ListTeams

func ListTeams() ([]Team, error)

func (*Team) AddUser

func (t *Team) AddUser(u *User) error

AddUser adds a user to the team.

func (*Team) AllowedApps

func (t *Team) AllowedApps() ([]string, error)

AllowedApps returns the apps that the team has access.

func (*Team) ContainsUser

func (t *Team) ContainsUser(u *User) bool

ContainsUser checks if the team contains the user.

func (*Team) RemoveUser

func (t *Team) RemoveUser(u *User) error

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 GetUserByEmail(email string) (*User, error)

func ListUsers

func ListUsers() ([]User, error)

ListUsers list all users registred in tsuru

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) AllowedApps

func (u *User) AllowedApps() ([]string, error)

func (*User) Create

func (u *User) Create() error

func (*User) Delete

func (u *User) Delete() error

func (*User) IsAdmin

func (u *User) IsAdmin() bool

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) 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) Teams

func (u *User) Teams() ([]Team, error)

Teams returns a slice containing all teams that the user is member of.

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