auth

package
v0.0.0-...-e22f67b Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2013 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUserAccess

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

func GetTeamsNames

func GetTeamsNames(teams []Team) []string

Types

type AuthenticationFailure

type AuthenticationFailure struct{}

func (AuthenticationFailure) Error

func (a AuthenticationFailure) Error() string

type Key

type Key struct {
	Name    string
	Content string
}

type Team

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

func (*Team) AddUser

func (t *Team) AddUser(u *User) 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
	ValidUntil time.Time
}

type User

type User struct {
	Email    string
	Password string
	Tokens   []Token
	Keys     []Key
}

func CheckToken

func CheckToken(token string) (*User, error)

func GetUserByEmail

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

func GetUserByToken

func GetUserByToken(token string) (*User, error)

func (*User) AddKey

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

func (*User) AllowedApps

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

func (*User) AllowedAppsByTeam

func (u *User) AllowedAppsByTeam(team string) ([]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) RemoveKey

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

func (*User) Teams

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

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

func (*User) Update

func (u *User) Update() error

Notes

Bugs

  • this function is deprecated, it's here for the migration phase (whenever a user login with the old hash, the new hash will be generated).

  • this is temporary code, for a migration phase in the hashing algorithm. In the future we should just use bcrypt.CompareHashAndPassword, and drop the old hash checking and update stuff.

Jump to

Keyboard shortcuts

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