Documentation ¶
Index ¶
- func LogRequestMiddleware(next fasthttp.RequestHandler) fasthttp.RequestHandler
- func NewRequestLogger(ctx *AutheliaCtx) *logrus.Entry
- func StripPathMiddleware(path string, next fasthttp.RequestHandler) fasthttp.RequestHandler
- type AutheliaCtx
- func (c AutheliaCtx) AcceptsMIME(mime string) (acceptsMime bool)
- func (c *AutheliaCtx) BasePath() (base string)
- func (c *AutheliaCtx) Error(err error, message string)
- func (c *AutheliaCtx) ExternalRootURL() (string, error)
- func (c *AutheliaCtx) GetOriginalURL() (*url.URL, error)
- func (c *AutheliaCtx) GetSession() session.UserSession
- func (c AutheliaCtx) IsXHR() (xhr bool)
- func (c *AutheliaCtx) ParseBody(value interface{}) error
- func (c *AutheliaCtx) RemoteIP() net.IP
- func (c *AutheliaCtx) ReplyBadRequest()
- func (c *AutheliaCtx) ReplyError(err error, message string)
- func (c *AutheliaCtx) ReplyForbidden()
- func (c *AutheliaCtx) ReplyOK()
- func (c *AutheliaCtx) ReplyUnauthorized()
- func (c *AutheliaCtx) SaveSession(userSession session.UserSession) error
- func (c *AutheliaCtx) SetJSONBody(value interface{}) error
- func (c *AutheliaCtx) SpecialRedirect(uri string, statusCode int)
- func (c *AutheliaCtx) XForwardedHost() []byte
- func (c *AutheliaCtx) XForwardedMethod() []byte
- func (c *AutheliaCtx) XForwardedProto() []byte
- func (c *AutheliaCtx) XForwardedURI() []byte
- func (c *AutheliaCtx) XOriginalURL() []byte
- type AutheliaHandlerFunc
- type ErrorResponse
- type IdentityVerificationClaim
- type IdentityVerificationFinishArgs
- type IdentityVerificationFinishBody
- type IdentityVerificationStartArgs
- type Middleware
- type OKResponse
- type Providers
- type RequestHandler
- func IdentityVerificationFinish(args IdentityVerificationFinishArgs, ...) RequestHandler
- func IdentityVerificationStart(args IdentityVerificationStartArgs) RequestHandler
- func NewHTTPToAutheliaHandlerAdaptor(h AutheliaHandlerFunc) RequestHandler
- func RequireFirstFactor(next RequestHandler) RequestHandler
- type RequestHandlerBridge
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogRequestMiddleware ¶
func LogRequestMiddleware(next fasthttp.RequestHandler) fasthttp.RequestHandler
LogRequestMiddleware logs the query that is being treated.
func NewRequestLogger ¶
func NewRequestLogger(ctx *AutheliaCtx) *logrus.Entry
NewRequestLogger create a new request logger for the given request.
func StripPathMiddleware ¶
func StripPathMiddleware(path string, next fasthttp.RequestHandler) fasthttp.RequestHandler
StripPathMiddleware strips the first level of a path.
Types ¶
type AutheliaCtx ¶
type AutheliaCtx struct { *fasthttp.RequestCtx Logger *logrus.Entry Providers Providers Configuration schema.Configuration Clock utils.Clock }
AutheliaCtx contains all server variables related to Authelia.
func NewAutheliaCtx ¶
func NewAutheliaCtx(ctx *fasthttp.RequestCtx, configuration schema.Configuration, providers Providers) (*AutheliaCtx, error)
NewAutheliaCtx instantiate an AutheliaCtx out of a RequestCtx.
func (AutheliaCtx) AcceptsMIME ¶
func (c AutheliaCtx) AcceptsMIME(mime string) (acceptsMime bool)
AcceptsMIME takes a mime type and returns true if the request accepts that type or the wildcard type.
func (*AutheliaCtx) BasePath ¶
func (c *AutheliaCtx) BasePath() (base string)
BasePath returns the base_url as per the path visited by the client.
func (*AutheliaCtx) Error ¶
func (c *AutheliaCtx) Error(err error, message string)
Error reply with an error and display the stack trace in the logs.
func (*AutheliaCtx) ExternalRootURL ¶
func (c *AutheliaCtx) ExternalRootURL() (string, error)
ExternalRootURL gets the X-Forwarded-Proto, X-Forwarded-Host headers and the BasePath and forms them into a URL.
func (*AutheliaCtx) GetOriginalURL ¶
func (c *AutheliaCtx) GetOriginalURL() (*url.URL, error)
GetOriginalURL extract the URL from the request headers (X-Original-URI or X-Forwarded-* headers).
func (*AutheliaCtx) GetSession ¶
func (c *AutheliaCtx) GetSession() session.UserSession
GetSession return the user session. Any update will be saved in cache.
func (AutheliaCtx) IsXHR ¶
func (c AutheliaCtx) IsXHR() (xhr bool)
IsXHR returns true if the request is a XMLHttpRequest.
func (*AutheliaCtx) ParseBody ¶
func (c *AutheliaCtx) ParseBody(value interface{}) error
ParseBody parse the request body into the type of value.
func (*AutheliaCtx) RemoteIP ¶
func (c *AutheliaCtx) RemoteIP() net.IP
RemoteIP return the remote IP taking X-Forwarded-For header into account if provided.
func (*AutheliaCtx) ReplyBadRequest ¶
func (c *AutheliaCtx) ReplyBadRequest()
ReplyBadRequest response sent when bad request has been sent.
func (*AutheliaCtx) ReplyError ¶
func (c *AutheliaCtx) ReplyError(err error, message string)
ReplyError reply with an error but does not display any stack trace in the logs.
func (*AutheliaCtx) ReplyForbidden ¶
func (c *AutheliaCtx) ReplyForbidden()
ReplyForbidden response sent when access is forbidden to user.
func (*AutheliaCtx) ReplyOK ¶
func (c *AutheliaCtx) ReplyOK()
ReplyOK is a helper method to reply ok.
func (*AutheliaCtx) ReplyUnauthorized ¶
func (c *AutheliaCtx) ReplyUnauthorized()
ReplyUnauthorized response sent when user is unauthorized.
func (*AutheliaCtx) SaveSession ¶
func (c *AutheliaCtx) SaveSession(userSession session.UserSession) error
SaveSession save the content of the session.
func (*AutheliaCtx) SetJSONBody ¶
func (c *AutheliaCtx) SetJSONBody(value interface{}) error
SetJSONBody Set json body.
func (*AutheliaCtx) SpecialRedirect ¶
func (c *AutheliaCtx) SpecialRedirect(uri string, statusCode int)
SpecialRedirect performs a redirect similar to fasthttp.RequestCtx except it allows statusCode 401 and includes body content in the form of a link to the location.
func (*AutheliaCtx) XForwardedHost ¶
func (c *AutheliaCtx) XForwardedHost() []byte
XForwardedHost return the content of the X-Forwarded-Host header.
func (*AutheliaCtx) XForwardedMethod ¶
func (c *AutheliaCtx) XForwardedMethod() []byte
XForwardedMethod return the content of the X-Forwarded-Method header.
func (*AutheliaCtx) XForwardedProto ¶
func (c *AutheliaCtx) XForwardedProto() []byte
XForwardedProto return the content of the X-Forwarded-Proto header.
func (*AutheliaCtx) XForwardedURI ¶
func (c *AutheliaCtx) XForwardedURI() []byte
XForwardedURI return the content of the X-Forwarded-URI header.
func (*AutheliaCtx) XOriginalURL ¶
func (c *AutheliaCtx) XOriginalURL() []byte
XOriginalURL return the content of the X-Original-URL header.
type AutheliaHandlerFunc ¶
type AutheliaHandlerFunc func(ctx *AutheliaCtx, rw http.ResponseWriter, r *http.Request)
AutheliaHandlerFunc is used with the NewHTTPToAutheliaHandlerAdaptor to encapsulate a func.
type ErrorResponse ¶
ErrorResponse model of an error response.
type IdentityVerificationClaim ¶
type IdentityVerificationClaim struct { jwt.StandardClaims // The action this token has been crafted for. Action string `json:"action"` // The user this token has been crafted for. Username string `json:"username"` }
IdentityVerificationClaim custom claim for specifying the action claim. The action can be to register a TOTP device, a U2F device or reset one's password.
type IdentityVerificationFinishArgs ¶
type IdentityVerificationFinishArgs struct { // The action claim that should be in the token to consider the action legitimate. ActionClaim string // The function for checking the user in the token is valid for the current action. IsTokenUserValidFunc func(ctx *AutheliaCtx, username string) bool }
IdentityVerificationFinishArgs represent the arguments used to customize the finishing phase of the identity verification process.
type IdentityVerificationFinishBody ¶
type IdentityVerificationFinishBody struct {
Token string `json:"token"`
}
IdentityVerificationFinishBody type of the body received by the finish endpoint.
type IdentityVerificationStartArgs ¶
type IdentityVerificationStartArgs struct { // Email template needs a subject, a title and the content of the button. MailTitle string MailButtonContent string // The target endpoint where to redirect the user when verification process // is completed successfully. TargetEndpoint string // The action claim that will be stored in the JWT token. ActionClaim string // The function retrieving the identity to who the email will be sent. IdentityRetrieverFunc func(ctx *AutheliaCtx) (*session.Identity, error) // The function for checking the user in the token is valid for the current action. IsTokenUserValidFunc func(ctx *AutheliaCtx, username string) bool }
IdentityVerificationStartArgs represent the arguments used to customize the starting phase of the identity verification process.
type Middleware ¶
type Middleware = func(RequestHandler) RequestHandler
Middleware represent an Authelia middleware.
type OKResponse ¶
type OKResponse struct { Status string `json:"status"` Data interface{} `json:"data,omitempty"` }
OKResponse model of a status OK response.
type Providers ¶
type Providers struct { Authorizer *authorization.Authorizer SessionProvider *session.Provider Regulator *regulation.Regulator OpenIDConnect oidc.OpenIDConnectProvider UserProvider authentication.UserProvider StorageProvider storage.Provider Notifier notification.Notifier }
Providers contain all provider provided to Authelia.
type RequestHandler ¶
type RequestHandler = func(*AutheliaCtx)
RequestHandler represents an Authelia request handler.
func IdentityVerificationFinish ¶
func IdentityVerificationFinish(args IdentityVerificationFinishArgs, next func(ctx *AutheliaCtx, username string)) RequestHandler
IdentityVerificationFinish the middleware for finishing the identity validation process.
func IdentityVerificationStart ¶
func IdentityVerificationStart(args IdentityVerificationStartArgs) RequestHandler
IdentityVerificationStart the handler for initiating the identity validation process.
func NewHTTPToAutheliaHandlerAdaptor ¶
func NewHTTPToAutheliaHandlerAdaptor(h AutheliaHandlerFunc) RequestHandler
NewHTTPToAutheliaHandlerAdaptor creates a new adaptor given the AutheliaHandlerFunc.
func RequireFirstFactor ¶
func RequireFirstFactor(next RequestHandler) RequestHandler
RequireFirstFactor check if user has enough permissions to execute the next handler.
type RequestHandlerBridge ¶
type RequestHandlerBridge = func(RequestHandler) fasthttp.RequestHandler
RequestHandlerBridge bridge a AutheliaCtx handle to a RequestHandler handler.
func AutheliaMiddleware ¶
func AutheliaMiddleware(configuration schema.Configuration, providers Providers) RequestHandlerBridge
AutheliaMiddleware is wrapping the RequestCtx into an AutheliaCtx providing Authelia related objects.