v4.33.2 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2022 License: Apache-2.0 Imports: 35 Imported by: 0




This section is empty.


This section is empty.


func AssetOverrideMiddleware added in v4.33.0

func AssetOverrideMiddleware(assetPath string, next fasthttp.RequestHandler) fasthttp.RequestHandler

AssetOverrideMiddleware allows overriding and serving of specific embedded assets from disk.

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.


type AutheliaCtx

type AutheliaCtx struct {

	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) SetJSONError added in v4.33.0

func (c *AutheliaCtx) SetJSONError(message string)

SetJSONError sets the body of the response to an JSON error KO message.

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

type ErrorResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`

ErrorResponse model of an error response.

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
	NTP             *ntp.Provider
	UserProvider    authentication.UserProvider
	StorageProvider storage.Provider
	Notifier        notification.Notifier
	TOTP            totp.Provider

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, delayFunc TimingAttackDelayFunc) 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.

type TimingAttackDelayFunc added in v4.33.2

type TimingAttackDelayFunc func(logger *logrus.Entry, requestTime time.Time, successful *bool)

TimingAttackDelayFunc describes a function for preventing timing attacks via a delay.

func TimingAttackDelay added in v4.33.2

func TimingAttackDelay(history int, minDelayMs float64, maxRandomMs int64, initialDelay time.Duration) TimingAttackDelayFunc

TimingAttackDelay creates a new standard timing delay func.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL