auth

package
v0.0.0-...-912c657 Latest Latest
Warning

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

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

Functions

func CheckUserAccess

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

func CreateTeam

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

func DeleteToken

func DeleteToken(token string) error

func GetTeamsNames

func GetTeamsNames(teams []Team) []string

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.

Types

type AuthenticationFailure

type AuthenticationFailure struct{}

func (AuthenticationFailure) Error

func (AuthenticationFailure) Error() string

type Key

type Key struct {
	Name    string
	Content string
}

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 struct {
	Token     string        `json:"token"`
	Creation  time.Time     `json:"creation"`
	Expires   time.Duration `json:"expires"`
	UserEmail string        `json:"email"`
	AppName   string        `json:"app"`
}

func CreateApplicationToken

func CreateApplicationToken(appName string) (*Token, error)

func GetToken

func GetToken(header string) (*Token, error)

func (*Token) User

func (t *Token) 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) AllowedApps

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

func (*User) CheckPassword

func (u *User) CheckPassword(password string) error

func (*User) Create

func (u *User) Create() error

func (*User) CreateToken

func (u *User) CreateToken(password string) (*Token, error)

func (*User) FindKey

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

func (*User) HasKey

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

func (*User) HashPassword

func (u *User) HashPassword()

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

func (u *User) ResetPassword(token string) error

ResetPassword actually resets the password of the user. It needs the token string. The new password will be a random string, that will be then sent to the user email.

func (*User) StartPasswordReset

func (u *User) StartPasswordReset() error

StartPasswordReset starts the password reset process, creating a new token and mailing it to the user.

The token should then be used to finish the process, through the ResetPassword function.

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

Jump to

Keyboard shortcuts

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