Documentation ¶
Overview ¶
Package controller defines common utilities used by web and API controllers.
Index ¶
- Constants
- func AuthorizedAppFromContext(ctx context.Context) *database.AuthorizedApp
- func Back(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func BindForm(w http.ResponseWriter, r *http.Request, data interface{}) error
- func BindJSON(w http.ResponseWriter, r *http.Request, data interface{}) error
- func ClearEmailVerificationPrompted(session *sessions.Session)
- func ClearLastActivity(session *sessions.Session)
- func ClearMFAPrompted(session *sessions.Session)
- func ClearPasswordExpireWarned(session *sessions.Session)
- func ClearSessionFactorCount(session *sessions.Session)
- func ClearSessionFirebaseCookie(session *sessions.Session)
- func ClearSessionRealm(session *sessions.Session)
- func ClearWelcomeMessageDisplayed(session *sessions.Session)
- func EmailVerificationPromptedFromSession(session *sessions.Session) bool
- func FactorCountFromSession(session *sessions.Session) uint
- func FirebaseCookieFromSession(session *sessions.Session) string
- func Flash(session *sessions.Session) *flash.Flash
- func HandleHealthz(hctx context.Context, cfg *database.Config, h *render.Renderer) http.Handler
- func InternalError(w http.ResponseWriter, r *http.Request, h *render.Renderer, err error)
- func IsJSONContentType(r *http.Request) bool
- func LastActivityFromSession(session *sessions.Session) time.Time
- func MFAPromptedFromSession(session *sessions.Session) bool
- func MissingAuthorizedApp(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func MissingRealm(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func MissingSession(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func MissingUser(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func PasswordExpireWarnedFromSession(session *sessions.Session) bool
- func RealmFromContext(ctx context.Context) *database.Realm
- func RealmIDFromSession(session *sessions.Session) uint
- func RedirectToChangePassword(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func RedirectToMFA(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func SessionFromContext(ctx context.Context) *sessions.Session
- func StorePasswordExpireWarned(session *sessions.Session, prompted bool)
- func StoreSessionEmailVerificationPrompted(session *sessions.Session, prompted bool)
- func StoreSessionFactorCount(session *sessions.Session, count uint)
- func StoreSessionFirebaseCookie(session *sessions.Session, firebaseCookie string)
- func StoreSessionLastActivity(session *sessions.Session, t time.Time)
- func StoreSessionMFAPrompted(session *sessions.Session, prompted bool)
- func StoreSessionRealm(session *sessions.Session, realm *database.Realm)
- func StoreSessionWelcomeMessageDisplayed(session *sessions.Session, prompted bool)
- func Unauthorized(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func UserFromContext(ctx context.Context) *database.User
- func WelcomeMessageDisplayedFromSession(session *sessions.Session) bool
- func WithAuthorizedApp(ctx context.Context, app *database.AuthorizedApp) context.Context
- func WithRealm(ctx context.Context, r *database.Realm) context.Context
- func WithSession(ctx context.Context, session *sessions.Session) context.Context
- func WithTemplateMap(ctx context.Context, m TemplateMap) context.Context
- func WithUser(ctx context.Context, u *database.User) context.Context
- type TemplateMap
Constants ¶
const ( ContentTypeJSON = "application/json" ContentTypeHTML = "text/html" )
Variables ¶
This section is empty.
Functions ¶
func AuthorizedAppFromContext ¶
func AuthorizedAppFromContext(ctx context.Context) *database.AuthorizedApp
AuthorizedAppFromContext retrieves the authorized app from the context. If no value exists, it returns nil.
func BindForm ¶
func BindForm(w http.ResponseWriter, r *http.Request, data interface{}) error
BindForm parses and binds the HTTP form to the provided data interface using the gorilla schema package.
func BindJSON ¶
func BindJSON(w http.ResponseWriter, r *http.Request, data interface{}) error
BindJSON provides a common implementation of JSON unmarshaling with well defined error handling.
func ClearEmailVerificationPrompted ¶ added in v0.9.0
ClearEmailVerificationPrompted clears the MFA prompt bit.
func ClearLastActivity ¶ added in v0.9.0
ClearLastActivity clears the session last activity time.
func ClearMFAPrompted ¶ added in v0.8.0
ClearMFAPrompted clears the MFA prompt bit.
func ClearPasswordExpireWarned ¶ added in v0.9.0
ClearPasswordExpireWarned clears the welcome message prompt bit.
func ClearSessionFactorCount ¶ added in v0.8.0
ClearSessionFactorCount clears the MFA factor count from the session.
func ClearSessionFirebaseCookie ¶
ClearSessionFirebaseCookie clears the firebase cookie from the session.
func ClearSessionRealm ¶
ClearSessionRealm clears the realm from the session.
func ClearWelcomeMessageDisplayed ¶ added in v0.9.0
ClearWelcomeMessageDisplayed clears the welcome message prompt bit.
func EmailVerificationPromptedFromSession ¶ added in v0.9.0
EmailVerificationPromptedFromSession extracts if the user was prompted for email verification.
func FactorCountFromSession ¶ added in v0.8.0
FactorCountFromSession extracts the number of MFA factors from the session.
func FirebaseCookieFromSession ¶
FirebaseCookieFromSession extracts the firebase cookie from the session.
func HandleHealthz ¶ added in v0.3.0
func InternalError ¶
InternalError handles an internal error, returning the right response to the client.
func IsJSONContentType ¶
IsJSONContentType returns true if the request's content type is application/json extra specific details, like UTF encoding schema are allowed.
func LastActivityFromSession ¶ added in v0.9.0
LastActivityFromSession extractsthe last time the user did something.
func MFAPromptedFromSession ¶ added in v0.8.0
MFAPromptedFromSession extracts if the user was prompted for MFA.
func MissingAuthorizedApp ¶
MissingAuthorizedApp returns an internal error when the authorized app does not exist.
func MissingRealm ¶
MissingRealm returns an error indicating that the request requires a realm selection, but one was not present.
func MissingSession ¶
MissingSession returns an internal error when the session does not exist.
func MissingUser ¶
MissingUser returns an internal error when the user does not exist.
func PasswordExpireWarnedFromSession ¶ added in v0.9.0
PasswordExpireWarnedFromSession extracts if the user was displayed the realm welcome message.
func RealmFromContext ¶
RealmFromContext retrieves the realm from the context. If no value exists, it returns nil.
func RealmIDFromSession ¶
RealmIDFromSession extracts the realm from the session.
func RedirectToChangePassword ¶ added in v0.9.0
RedirectToChangePassword redirects to the password reset page.
func RedirectToMFA ¶ added in v0.8.0
RedirectToMFA redirects to the MFA registration.
func SessionFromContext ¶
SessionFromContext retrieves the session on the provided context. If no session exists, or if the value in the context is not of the correct type, it returns nil.
func StorePasswordExpireWarned ¶ added in v0.9.0
StorePasswordExpireWarned stores if the user was displayed the realm welcome message.
func StoreSessionEmailVerificationPrompted ¶ added in v0.9.0
StoreSessionEmailVerificationPrompted stores if the user was prompted for email verification.
func StoreSessionFactorCount ¶ added in v0.8.0
StoreSessionFactorCount stores count of MFA factors to session.
func StoreSessionFirebaseCookie ¶
StoreSessionFirebaseCookie stores the firebase cookie in the session. If the provided session or cookie is nil/empty, it does nothing.
func StoreSessionLastActivity ¶ added in v0.9.0
StoreSessionLastActivity stores the last time the user did something. This is used to track idle session timeouts.
func StoreSessionMFAPrompted ¶ added in v0.8.0
StoreSessionMFAPrompted stores if the user was prompted for MFA.
func StoreSessionRealm ¶
StoreSessionRealm stores the realm's ID in the session.
func StoreSessionWelcomeMessageDisplayed ¶ added in v0.9.0
StoreSessionWelcomeMessageDisplayed stores if the user was displayed the realm welcome message.
func Unauthorized ¶
Unauthorized returns an error indicating the request was unauthorized.
func UserFromContext ¶
UserFromContext retrieves the user from the context. If no value exists, it returns nil.
func WelcomeMessageDisplayedFromSession ¶ added in v0.9.0
WelcomeMessageDisplayedFromSession extracts if the user was displayed the realm welcome message.
func WithAuthorizedApp ¶
WithAuthorizedApp stores the authorized app on the context.
func WithSession ¶
WithSession stores the session on the request's context for retrieval later. Use Session(r) to retrieve the session.
func WithTemplateMap ¶
func WithTemplateMap(ctx context.Context, m TemplateMap) context.Context
WithTemplateMap creates a context with the given template map.
Types ¶
type TemplateMap ¶
type TemplateMap map[string]interface{}
TemplateMap is a typemap for the HTML templates.
func TemplateMapFromContext ¶
func TemplateMapFromContext(ctx context.Context) TemplateMap
TemplateMapFromContext gets the template map on the context. If no map exists, it returns an empty map.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package admin contains controllers for system wide administrative actions.
|
Package admin contains controllers for system wide administrative actions. |
Package apikey contains web controllers for listing and adding API Keys.
|
Package apikey contains web controllers for listing and adding API Keys. |
Package certapi implements the token + TEK verification API.
|
Package certapi implements the token + TEK verification API. |
Package cleanup implements periodic data deletion.
|
Package cleanup implements periodic data deletion. |
Package codestatus defines a web controller for the code status page of the verification server.
|
Package codestatus defines a web controller for the code status page of the verification server. |
Package flash implements flash messages.
|
Package flash implements flash messages. |
Package home defines a web controller for the home page of the verification server.
|
Package home defines a web controller for the home page of the verification server. |
Package issueapi implements the API handler for taking a code request, assigning an OTP, saving it to the database and returning the result.
|
Package issueapi implements the API handler for taking a code request, assigning an OTP, saving it to the database and returning the result. |
Package jwks handles returning JSON encoded information about the server's encryptionn keys.
|
Package jwks handles returning JSON encoded information about the server's encryptionn keys. |
Package login defines the controller for the login page.
|
Package login defines the controller for the login page. |
Package middleware contains application specific gin middleware functions.
|
Package middleware contains application specific gin middleware functions. |
Package modeler implements periodic statistical calculations.
|
Package modeler implements periodic statistical calculations. |
Package realmadmin contains web controllers for changing realm settings.
|
Package realmadmin contains web controllers for changing realm settings. |
Package realmkeys contains web controllers for realm certificate key management.
|
Package realmkeys contains web controllers for realm certificate key management. |
Package redirect defines the controller for the deep link redirector.
|
Package redirect defines the controller for the deep link redirector. |
Package user contains web controllers for listing and adding users.
|
Package user contains web controllers for listing and adding users. |
Package verifyapi implements the exchange of the verification code (short term token) for a long term token that can be used to get a verification certification to send to the key server.
|
Package verifyapi implements the exchange of the verification code (short term token) for a long term token that can be used to get a verification certification to send to the key server. |