auth

package
v1.4.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(m models.AuthModel) (*models.User, error)

Login authenticates user credentials based on setting.

func OnBoardUser

func OnBoardUser(user *models.User) error

OnBoardUser will check if a user exists in user table, if not insert the user and put the id in the pointer of user model, if it does exist, return the user's profile.

func PostAuthenticate

func PostAuthenticate(u *models.User) error

PostAuthenticate -

func Register

func Register(name string, h AuthenticateHelper)

Register add different authenticators to registry map.

func SearchUser

func SearchUser(username string) (*models.User, error)

SearchUser --

Types

type AuthenticateHelper

type AuthenticateHelper interface {

	// Authenticate ...
	Authenticate(m models.AuthModel) (*models.User, error)
	// OnBoardUser will check if a user exists in user table, if not insert the user and
	// put the id in the pointer of user model, if it does exist, fill in the user model based
	// on the data record of the user
	OnBoardUser(u *models.User) error
	// Get user information from account repository
	SearchUser(username string) (*models.User, error)
	// Update user information after authenticate, such as Onboard or sync info etc
	PostAuthenticate(u *models.User) error
}

AuthenticateHelper provides interface for user management in different auth modes.

type DefaultAuthenticateHelper

type DefaultAuthenticateHelper struct {
}

DefaultAuthenticateHelper - default AuthenticateHelper implementation

func (*DefaultAuthenticateHelper) Authenticate

func (d *DefaultAuthenticateHelper) Authenticate(m models.AuthModel) (*models.User, error)

Authenticate ...

func (*DefaultAuthenticateHelper) OnBoardUser

func (d *DefaultAuthenticateHelper) OnBoardUser(u *models.User) error

OnBoardUser will check if a user exists in user table, if not insert the user and put the id in the pointer of user model, if it does exist, fill in the user model based on the data record of the user

func (*DefaultAuthenticateHelper) PostAuthenticate

func (d *DefaultAuthenticateHelper) PostAuthenticate(u *models.User) error

PostAuthenticate - Update user information after authenticate, such as Onboard or sync info etc

func (*DefaultAuthenticateHelper) SearchUser

func (d *DefaultAuthenticateHelper) SearchUser(username string) (*models.User, error)

SearchUser - Get user information from account repository

type UserLock

type UserLock struct {
	// contains filtered or unexported fields
}

UserLock maintains a lock to block user from logging in within a short period of time.

func NewUserLock

func NewUserLock(freeze time.Duration) *UserLock

NewUserLock ...

func (*UserLock) IsLocked

func (ul *UserLock) IsLocked(username string) bool

IsLocked checks whether a login request is happened within a period of time or not if it is, the authenticator should ignore the login request and return a failure immediately

func (*UserLock) Lock

func (ul *UserLock) Lock(username string)

Lock marks a new login failure with the time it happens

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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