Documentation ¶
Index ¶
- type Controller
- func (coreModule *Controller) BindAPI(router *web.Router)
- func (coreModule *Controller) BindActionHandler(action api.TokenAction, thi TokenHandler)
- func (coreModule *Controller) BindEventHandler(name string, ehi EventHandler)
- func (coreModule *Controller) BindModule(name string, mod interface{})
- func (coreModule *Controller) BindPostLoginFailure(name string, plfi PostLoginFailureHook)
- func (coreModule *Controller) BindPostLoginSuccess(name string, plsi PostLoginSuccessHook)
- func (coreModule *Controller) BindPreLogin(name string, lhi PreLoginHook)
- func (coreModule *Controller) BindSecondFactor(name string, sfi SecondFactorProvider)
- func (coreModule *Controller) CheckSecondFactors(userid string) (bool, map[string]bool)
- func (coreModule *Controller) HandleRecoveryToken(email string, tokenString string) (bool, interface{}, error)
- func (coreModule *Controller) HandleToken(userid string, user interface{}, tokenString string) (bool, error)
- func (coreModule *Controller) PasswordResetStart(email string, meta map[string]string) error
- func (coreModule *Controller) PostLoginFailure(u interface{}) error
- func (coreModule *Controller) PostLoginSuccess(u interface{}) error
- func (coreModule *Controller) PreLogin(u interface{}) (bool, error)
- func (coreModule *Controller) SecondFactorCompleted(userid, action string)
- type EventHandler
- type LoginProvider
- type PostLoginFailureHook
- type PostLoginSuccessHook
- type PreLoginHook
- type SecondFactorProvider
- type TokenHandler
- type TokenValidator
- type UserInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller core module instance storage The core module implements basic login/logout methods and allows binding of modules To interrupt/assist/log the execution of each
func NewController ¶
func NewController(tokenValidator TokenValidator, loginProvider LoginProvider, emitter events.Emitter) *Controller
NewController Create a new core module instance
func (*Controller) BindAPI ¶
func (coreModule *Controller) BindAPI(router *web.Router)
BindAPI Binds the API for the coreModule to the provided router
func (*Controller) BindActionHandler ¶
func (coreModule *Controller) BindActionHandler(action api.TokenAction, thi TokenHandler)
BindActionHandler Binds a token action handler instance to the core module Token actions are validated and executed following successful login
func (*Controller) BindEventHandler ¶
func (coreModule *Controller) BindEventHandler(name string, ehi EventHandler)
BindEventHandler Binds an event handler interface into the core module Event handlers are called during a variety of evens
func (*Controller) BindModule ¶
func (coreModule *Controller) BindModule(name string, mod interface{})
BindModule Magic binding function, detects interfaces implemented by a given module and binds as appropriate
func (*Controller) BindPostLoginFailure ¶
func (coreModule *Controller) BindPostLoginFailure(name string, plfi PostLoginFailureHook)
BindPostLoginFailure binds a PostLoginFailure handler interface to the core module This handler will be called on failed logins
func (*Controller) BindPostLoginSuccess ¶
func (coreModule *Controller) BindPostLoginSuccess(name string, plsi PostLoginSuccessHook)
BindPostLoginSuccess binds a PostLoginSuccess handler interface to the core module This handler will be called on successful logins
func (*Controller) BindPreLogin ¶
func (coreModule *Controller) BindPreLogin(name string, lhi PreLoginHook)
BindPreLogin Binds a PreLogin handler interface to the core module PreLogin handlers are called in the login chain to check login requirements
func (*Controller) BindSecondFactor ¶
func (coreModule *Controller) BindSecondFactor(name string, sfi SecondFactorProvider)
BindSecondFactor Binds a 2fa handler instance into the core module 2fa handlers must return whether they are available for a given user. If any 2fa module returns true, login will be halted, the user alerted (with available options), and a 2fa-pending session variable set in the global context for a 2fa implementation to pick up
func (*Controller) CheckSecondFactors ¶
func (coreModule *Controller) CheckSecondFactors(userid string) (bool, map[string]bool)
CheckSecondFactors Determine whether a second factor is required for a user This returns a bool indicating whether 2fa is required, and a map of the available 2fa mechanisms
func (*Controller) HandleRecoveryToken ¶
func (coreModule *Controller) HandleRecoveryToken(email string, tokenString string) (bool, interface{}, error)
HandleRecoveryToken handles a password reset or account recovery token
func (*Controller) HandleToken ¶
func (coreModule *Controller) HandleToken(userid string, user interface{}, tokenString string) (bool, error)
HandleToken Handles a token string for a given user Returns accepted bool and error in case of failure
func (*Controller) PasswordResetStart ¶
func (coreModule *Controller) PasswordResetStart(email string, meta map[string]string) error
PasswordResetStart Starts a password reset session
func (*Controller) PostLoginFailure ¶
func (coreModule *Controller) PostLoginFailure(u interface{}) error
PostLoginFailure Runs bound post login failure handlers
func (*Controller) PostLoginSuccess ¶
func (coreModule *Controller) PostLoginSuccess(u interface{}) error
PostLoginSuccess Runs bound post login success handlers
func (*Controller) PreLogin ¶
func (coreModule *Controller) PreLogin(u interface{}) (bool, error)
PreLogin Runs bound login handlers to accept user logins
func (*Controller) SecondFactorCompleted ¶
func (coreModule *Controller) SecondFactorCompleted(userid, action string)
SecondFactorCompleted handles completion of a 2fa provider
type EventHandler ¶
EventHandler Interface for event handler modules These modules are bound into the event manager to provide asynchronous services based on system events. For example, the mailer module accepts a variety of user events and sends mail in response.
type LoginProvider ¶
type LoginProvider interface { // Login method, returns boolean result, user interface for further use, error in case of failure Login(email string, password string) (bool, interface{}, error) GetUserByEmail(email string) (interface{}, error) }
LoginProvider Interface for a user control module
type PostLoginFailureHook ¶
type PostLoginFailureHook interface {
PostLoginFailure(u interface{}) error
}
PostLoginFailureHook Post login failure hooks called on login failure
type PostLoginSuccessHook ¶
type PostLoginSuccessHook interface {
PostLoginSuccess(u interface{}) error
}
PostLoginSuccessHook Post login success hooks called on login success
type PreLoginHook ¶
PreLoginHook PreLogin hooks may allow or deny login
type SecondFactorProvider ¶
type SecondFactorProvider interface { // Check whether a user can use this 2fa module // This depends on what second factors are registered IsSupported(userid string) bool }
SecondFactorProvider for 2 factor authentication modules These modules must inform the login handler as to whether further authentication is supported
type TokenHandler ¶
type TokenHandler interface {
HandleToken(userid string, tokenAction api.TokenAction) error
}
TokenHandler for token handler modules These modules accept a token action and user id to execute a task For example, the user module accepts 'activate' and 'unlock' actions
type TokenValidator ¶
type TokenValidator interface {
ValidateToken(userid string, tokenString string) (*api.TokenAction, error)
}
TokenValidator Interface for token validation
type UserInterface ¶
UserInterface Interface for user instances