auth

package
v0.0.0-...-df9d84e Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2014 License: BSD-3-Clause Imports: 15 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 ErrInvalidToken = errors.New("Invalid token")
View Source
var ErrUserNotFound = stderrors.New("User not found")

Functions

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

func CreateTeam

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

func GetTeamsNames

func GetTeamsNames(teams []Team) []string

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 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 AuthenticationFailure

type AuthenticationFailure struct {
	Message string
}

func (AuthenticationFailure) Error

func (a AuthenticationFailure) Error() string

type Key

type Key struct {
	Name    string
	Content 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)
	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(token Token) 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"`
}

func GetTeam

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

func (*Team) AddUser

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

func (*Team) AllowedApps

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

func (*Team) ContainsUser

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

func (*Team) RemoveUser

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

type Token

type Token interface {
	GetValue() string
	GetAppName() string
	GetUserName() string
	IsAppToken() bool
	User() (*User, error)
}

type User

type User struct {
	Email    string
	Password string
	Keys     []Key
	quota.Quota
}

func GetUserByEmail

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

func (*User) AddKey

func (u *User) AddKey(key Key) error

func (*User) AddKeyGandalf

func (u *User) AddKeyGandalf(key *Key) error

func (*User) AllowedApps

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

func (*User) Create

func (u *User) Create() error

func (*User) CreateOnGandalf

func (u *User) CreateOnGandalf() error

func (*User) Delete

func (u *User) Delete() error

func (*User) FindKey

func (u *User) FindKey(key Key) (Key, int)

func (*User) HasKey

func (u *User) HasKey(key Key) bool

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) ListKeys

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

func (*User) RemoveKey

func (u *User) RemoveKey(key Key) 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