Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( StatusAuthFailure = errors.New("auth: authencicated failed") ErrFailFindingUser = errors.New("user: user not found") ErrDuplicateUsername = errors.New("user existed") ErrDuplicateEmail = errors.New("user existed") ErrInvalidCredential = errors.New("auth: invalid credential") ErrTokenNotFound = errors.New("auth: token not found") ErrInvalidToken = errors.New("auth: invalid token") ErrSecretKeyNotfound = errors.New("auth: secret key not found") )
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a struct aim to seperate gorm Connection from the rest of the logical code
func (Engine) API ¶
func (e Engine) API() gin.HandlerFunc
API is a Authentication middleware for APIs
func (Engine) GetRequestCredential ¶
GetRequestCredential get username from request Return (username, nil) if successfully, else return ("", error)
func (Engine) Validate ¶
Validate user before accessing something Compare username that extract from tokenString and provided uname Return nil if validated, else return error
func (Engine) View ¶
func (e Engine) View() gin.HandlerFunc
View is a Authentication middleware for view
type IAuth ¶
type IAuth interface { Auth(u UserAuth) (string, error) Verify(u model.User) error GetRequestCredential(tokenString string) (string, error) Validate(uname, tokenString string) error View() gin.HandlerFunc API() gin.HandlerFunc }
func New ¶
func New(ur databaserepo.IUserRepo) IAuth
New create new instance of Authentication Engine
Click to show internal directories.
Click to hide internal directories.