Documentation ¶
Index ¶
- Constants
- func CorsOption(corsOptions *model.CorsOptions) func(*Router) error
- func GetFlash(w http.ResponseWriter, r *http.Request, name string) (string, error)
- func HostOption(host string) func(r *Router) error
- func NewRouter(logger *log.Logger, as model.AppStorage, us model.UserStorage, ...) (model.Router, error)
- func PathPrefixOptions(prefix string) func(r *Router) error
- func SetFlash(w http.ResponseWriter, name, value string)
- type Error
- type Router
- func (ar *Router) AppID() negroni.HandlerFunc
- func (ar *Router) DisableTFA() http.HandlerFunc
- func (ar *Router) DisableTFAHandler() http.HandlerFunc
- func (ar *Router) DumpRequest() negroni.HandlerFunc
- func (ar *Router) Error(w http.ResponseWriter, err error, code int, userInfo string)
- func (ar *Router) HTMLFileHandler(templateName string) http.HandlerFunc
- func (ar *Router) Login() http.HandlerFunc
- func (ar *Router) LoginHandler() http.HandlerFunc
- func (ar *Router) Logout() http.HandlerFunc
- func (ar *Router) Register() http.HandlerFunc
- func (ar *Router) RegistrationHandler() http.HandlerFunc
- func (ar *Router) RenewToken() http.HandlerFunc
- func (ar *Router) ResetPassword() http.HandlerFunc
- func (ar *Router) ResetPasswordHandler() http.HandlerFunc
- func (ar *Router) ResetTFA() http.HandlerFunc
- func (ar *Router) ResetTFAHandler() http.HandlerFunc
- func (ar *Router) ResetTokenMiddleware() negroni.HandlerFunc
- func (ar *Router) SendResetToken() http.HandlerFunc
- func (ar *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
const (
// CookieKeyWebCookieToken cookie key to keep the web cookie token.
CookieKeyWebCookieToken = "identifo-user"
)
const ( // ErrorRegistrationForbidden means that registration is forbidden. ErrorRegistrationForbidden = Error("Registration in this app is forbidden.") )
const (
// FlashErrorMessageKey flash message key to keep error message across pages.
FlashErrorMessageKey = "error"
)
const (
// FormKeyAppID is a form key to keep application ID.
FormKeyAppID = "appId"
)
Variables ¶
This section is empty.
Functions ¶
func CorsOption ¶
func CorsOption(corsOptions *model.CorsOptions) func(*Router) error
CorsOption sets cors option.
func NewRouter ¶
func NewRouter(logger *log.Logger, as model.AppStorage, us model.UserStorage, sfs model.StaticFilesStorage, ts model.TokenStorage, tb model.TokenBlacklist, tServ jwtService.TokenService, smsServ model.SMSService, emailServ model.EmailService, authorizer *authorization.Authorizer, options ...func(*Router) error) (model.Router, error)
NewRouter creates and initializes new router.
func PathPrefixOptions ¶
PathPrefixOptions set path prefix options.
func SetFlash ¶
func SetFlash(w http.ResponseWriter, name, value string)
SetFlash sets new flash message
Types ¶
type Router ¶
type Router struct { Middleware *negroni.Negroni Logger *log.Logger Router *mux.Router AppStorage model.AppStorage UserStorage model.UserStorage TokenStorage model.TokenStorage TokenBlacklist model.TokenBlacklist TokenService jwtService.TokenService SMSService model.SMSService EmailService model.EmailService Authorizer *authorization.Authorizer PathPrefix string Host string // contains filtered or unexported fields }
Router handles incoming http connections.
func (*Router) AppID ¶
func (ar *Router) AppID() negroni.HandlerFunc
AppID gets app id from the request body.
func (*Router) DisableTFA ¶
func (ar *Router) DisableTFA() http.HandlerFunc
DisableTFA handles TFA disablement form submission (POST request).
func (*Router) DisableTFAHandler ¶
func (ar *Router) DisableTFAHandler() http.HandlerFunc
DisableTFAHandler handles disable TFA GET request.
func (*Router) DumpRequest ¶
func (ar *Router) DumpRequest() negroni.HandlerFunc
DumpRequest dumps request to logger.
func (*Router) HTMLFileHandler ¶
func (ar *Router) HTMLFileHandler(templateName string) http.HandlerFunc
HTMLFileHandler receives path to a template and serves it over HTTP.
func (*Router) Login ¶
func (ar *Router) Login() http.HandlerFunc
Login logs user in with email and password.
func (*Router) LoginHandler ¶
func (ar *Router) LoginHandler() http.HandlerFunc
LoginHandler serves login page or redirects to the callback_url if user is already authenticated.
func (*Router) RegistrationHandler ¶
func (ar *Router) RegistrationHandler() http.HandlerFunc
RegistrationHandler serves registration page.
func (*Router) RenewToken ¶
func (ar *Router) RenewToken() http.HandlerFunc
RenewToken creates new id_token if user is already authenticated.
func (*Router) ResetPassword ¶
func (ar *Router) ResetPassword() http.HandlerFunc
ResetPassword handles password reset form submission (POST request).
func (*Router) ResetPasswordHandler ¶
func (ar *Router) ResetPasswordHandler() http.HandlerFunc
ResetPasswordHandler handles reset password GET request.
func (*Router) ResetTFA ¶
func (ar *Router) ResetTFA() http.HandlerFunc
ResetTFA handles TFA resetting form submission (POST request).
func (*Router) ResetTFAHandler ¶
func (ar *Router) ResetTFAHandler() http.HandlerFunc
ResetTFAHandler handles reset TFA GET request.
func (*Router) ResetTokenMiddleware ¶
func (ar *Router) ResetTokenMiddleware() negroni.HandlerFunc
ResetTokenMiddleware extracts reset token and validates it.
func (*Router) SendResetToken ¶
func (ar *Router) SendResetToken() http.HandlerFunc
SendResetToken POST form request handle with password request handle