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 BadRequest(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 CSRFTokenFromSession(session *sessions.Session) []byte
- func ClearEmailVerificationPrompted(session *sessions.Session)
- func ClearLastActivity(session *sessions.Session)
- func ClearMFAPrompted(session *sessions.Session)
- func ClearNonceFromSession(session *sessions.Session)
- func ClearPasswordExpireWarned(session *sessions.Session)
- func ClearSessionCSRFToken(session *sessions.Session)
- func ClearSessionRealm(session *sessions.Session)
- func ClearWelcomeMessageDisplayed(session *sessions.Session)
- func EmailVerificationPromptedFromSession(session *sessions.Session) bool
- func FirebaseUserFromContext(ctx context.Context) *auth.UserRecord
- func Flash(session *sessions.Session) *flash.Flash
- func HandleHealthz(pinger driver.Pinger, h *render.Renderer, isMaintenanceMode bool) 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 LocaleFromContext(ctx context.Context) gotext.Translator
- func MFAPromptedFromSession(session *sessions.Session) bool
- func MembershipFromContext(ctx context.Context) *database.Membership
- func MembershipsFromContext(ctx context.Context) []*database.Membership
- func MissingAuthorizedApp(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func MissingLocale(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func MissingMembership(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 NonceFromContext(ctx context.Context) string
- func NonceFromSession(session *sessions.Session) string
- func NotFound(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func OperatingSystemFromContext(ctx context.Context) database.OSType
- 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 RedirectToLogout(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func RedirectToMFA(w http.ResponseWriter, r *http.Request, h *render.Renderer)
- func RegionFromSession(session *sessions.Session) string
- func RequestIDFromContext(ctx context.Context) string
- func SendEmailVerificationEmailFunc(ctx context.Context, db *database.Database, h *render.Renderer, email string, ...) (auth.EmailVerificationEmailFunc, error)
- func SendInviteEmailFunc(ctx context.Context, db *database.Database, h *render.Renderer, email string, ...) (auth.InviteUserEmailFunc, error)
- func SendPasswordResetEmailFunc(ctx context.Context, db *database.Database, h *render.Renderer, email string, ...) (auth.ResetPasswordEmailFunc, error)
- func SessionFromContext(ctx context.Context) *sessions.Session
- func StorePasswordExpireWarned(session *sessions.Session, prompted bool)
- func StoreSessionCSRFToken(session *sessions.Session, token []byte)
- func StoreSessionEmailVerificationPrompted(session *sessions.Session, prompted bool)
- func StoreSessionLastActivity(session *sessions.Session, t time.Time)
- func StoreSessionMFAPrompted(session *sessions.Session, prompted bool)
- func StoreSessionNonce(session *sessions.Session, nonce string)
- func StoreSessionRealm(session *sessions.Session, realm *database.Realm)
- func StoreSessionRegion(session *sessions.Session, region string)
- 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 WithFirebaseUser(ctx context.Context, u *auth.UserRecord) context.Context
- func WithLocale(ctx context.Context, locale gotext.Translator) context.Context
- func WithMembership(ctx context.Context, u *database.Membership) context.Context
- func WithMemberships(ctx context.Context, u []*database.Membership) context.Context
- func WithNonce(ctx context.Context, nonce string) context.Context
- func WithOperatingSystem(ctx context.Context, os database.OSType) context.Context
- func WithRealm(ctx context.Context, r *database.Realm) context.Context
- func WithRequestID(ctx context.Context, id string) 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 Back ¶ added in v0.3.0
Back goes back to the referrer. If the referrer is missing, or if the referrer base URL does not match the request base URL, the redirect is to the homepage.
func BadRequest ¶ added in v0.19.0
BadRequest indicates the client sent an invalid request.
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 CSRFTokenFromSession ¶ added in v0.26.0
CSRFTokenFromSession extracts the CSRF token from the session.
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 ClearNonceFromSession ¶ added in v0.26.0
ClearNonceFromSession removes the nonce key from the current session.
func ClearPasswordExpireWarned ¶ added in v0.9.0
ClearPasswordExpireWarned clears the welcome message prompt bit.
func ClearSessionCSRFToken ¶ added in v0.26.0
ClearSessionCSRFToken clears the CSRF token 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 FirebaseUserFromContext ¶ added in v0.10.0
func FirebaseUserFromContext(ctx context.Context) *auth.UserRecord
FirebaseUserFromContext retrieves the firebase user from the context. If no value exists, it returns nil.
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 extracts the last time the user did something.
func LocaleFromContext ¶ added in v0.28.0
func LocaleFromContext(ctx context.Context) gotext.Translator
LocaleFromContext returns nil or the local from the context.
func MFAPromptedFromSession ¶ added in v0.8.0
MFAPromptedFromSession extracts if the user was prompted for MFA.
func MembershipFromContext ¶ added in v0.19.0
func MembershipFromContext(ctx context.Context) *database.Membership
MembershipFromContext retrieves the membership from the context. If no value exists, it returns nil.
func MembershipsFromContext ¶ added in v0.19.0
func MembershipsFromContext(ctx context.Context) []*database.Membership
MembershipsFromContext retrieves the membership from the context. If no value exists, it returns nil.
func MissingAuthorizedApp ¶
MissingAuthorizedApp returns an internal error when the authorized app does not exist.
func MissingLocale ¶ added in v0.31.0
MissingLocale returns an internal error when the locale does not exist.
func MissingMembership ¶ added in v0.19.0
MissingMembership 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 NonceFromContext ¶ added in v0.26.0
NonceFromContext retrieves a nonce value from the context.
func NonceFromSession ¶ added in v0.26.0
NonceFromSession returns the current nonce from the session or empty string if there isn't one, or the value is malformed.
func OperatingSystemFromContext ¶ added in v0.26.0
OperatingSystemFromContext retrieves the operating system enum from the context. If no value exists, UnknownOS is returned.
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 RedirectToLogout ¶ added in v0.19.0
RedirectToLogout redirects the user to the logout page to terminate the session.
func RedirectToMFA ¶ added in v0.8.0
RedirectToMFA redirects to the MFA registration.
func RegionFromSession ¶ added in v0.26.0
RegionFromSession returns the current region from the session or empty string if there isn't one, or the value is malformed.
func RequestIDFromContext ¶ added in v0.16.0
RequestIDFromContext retrieves the request ID from the context. If no value exists, it returns the empty string.
func SendEmailVerificationEmailFunc ¶ added in v0.15.0
func SendEmailVerificationEmailFunc(ctx context.Context, db *database.Database, h *render.Renderer, email string, realm *database.Realm) (auth.EmailVerificationEmailFunc, error)
SendEmailVerificationEmailFunc returns a function capable of sending an email verification email.
func SendInviteEmailFunc ¶ added in v0.15.0
func SendInviteEmailFunc(ctx context.Context, db *database.Database, h *render.Renderer, email string, realm *database.Realm) (auth.InviteUserEmailFunc, error)
SendInviteEmailFunc returns a function capable of sending a new user invitation.
func SendPasswordResetEmailFunc ¶ added in v0.15.0
func SendPasswordResetEmailFunc(ctx context.Context, db *database.Database, h *render.Renderer, email string, realm *database.Realm) (auth.ResetPasswordEmailFunc, error)
SendPasswordResetEmailFunc returns a function capable of sending a password reset for the given user.
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 StoreSessionCSRFToken ¶ added in v0.26.0
StoreSessionCSRFToken stores the CSRF token on the session.
func StoreSessionEmailVerificationPrompted ¶ added in v0.9.0
StoreSessionEmailVerificationPrompted stores if the user was prompted for email verification.
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 StoreSessionNonce ¶ added in v0.26.0
StoreSessionNonce stores this sessions current nonce value for processing.
func StoreSessionRealm ¶
StoreSessionRealm stores the realm's ID in the session.
func StoreSessionRegion ¶ added in v0.26.0
StoreSessionRegion stores the current operating region 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. The system always returns 401 (even with authentication is provided but authorization fails).
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 WithFirebaseUser ¶ added in v0.10.0
WithFirebaseUser stores the current firebase user on the context.
func WithLocale ¶ added in v0.28.0
WithLocale adds the translator / locale to use for this request.
func WithMembership ¶ added in v0.19.0
WithMembership stores the current membership on the context.
func WithMemberships ¶ added in v0.19.0
WithMemberships stores the user's available memberships on the context.
func WithOperatingSystem ¶ added in v0.26.0
WithOperatingSystem stores the operating system enum in the context.
func WithRealm ¶
WithRealm stores the current realm on the context and the realm.ID on the observability context.
func WithRequestID ¶ added in v0.16.0
WithRequestID stores the request ID 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.
func (TemplateMap) Title ¶ added in v0.16.0
func (m TemplateMap) Title(f string, args ...interface{})
Title sets the title on the template map. If a title already exists, the new value is prepended.
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 appsync syncs the published list of mobile apps to this server's db.
|
Package appsync syncs the published list of mobile apps to this server's db. |
Package associated handles the iOS and Android associated app handler protocols.
|
Package associated handles the iOS and Android associated app handler protocols. |
Package backup implements data and database backups.
|
Package backup implements data and database backups. |
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 codes defines a web controller for the code status page of the verification server.
|
Package codes defines a web controller for the code status page of the verification server. |
Package e2erunner implements the end-to-end runner.
|
Package e2erunner implements the end-to-end runner. |
Package flash implements flash messages.
|
Package flash implements flash messages. |
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 encryption keys.
|
Package jwks handles returning JSON encoded information about the server's encryption keys. |
Package login defines the controller for the login page.
|
Package login defines the controller for the login page. |
Code generated by gen-metrics-registrar.
|
Code generated by gen-metrics-registrar. |
Package middleware contains application specific gin middleware functions.
|
Package middleware contains application specific gin middleware functions. |
Package mobileapps contains web controllers for listing and adding mobile apps.
|
Package mobileapps contains web controllers for listing and adding mobile apps. |
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 rotation implements periodic secret rotation.
|
Package rotation implements periodic secret rotation. |
Package smskeys contains web controllers for realm certificate key management.
|
Package smskeys contains web controllers for realm certificate key management. |
Package stats produces statistics.
|
Package stats produces statistics. |
Package statspuller pulls statistics from the key server.
|
Package statspuller pulls statistics from the key server. |
Package user contains web controllers for listing and adding users.
|
Package user contains web controllers for listing and adding users. |
Package userreport defines the controller for the login page.
|
Package userreport defines the controller for the login page. |
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. |