Documentation
¶
Index ¶
Constants ¶
View Source
const ( // CtxAuthenticated is the authenticated field in request context. It is // of type bool and set to true, if the request has been successfully, // authenticated and false otherwise. CtxAuthenticated ctxKey = "authenticated" // CtxUsername is the username field in request context. CtxUsername ctxKey = "username" // CtxProtocol is the protocol field in request context. CtxProtocol ctxKey = "protocol" )
Context keys.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func New ¶
func New(authers []Auther) Authenticator
func (*Authenticator) Middleware ¶
func (a *Authenticator) Middleware(opts ...MiddlewareOption) func(next http.HandlerFunc) http.HandlerFunc
Middleware returns a http handler middleware, which will try to authenticate a request by probing all provided authers in sequence. When successful, the authenticated username and the protocol of the authentication is stored in the request context.
type MiddlewareOption ¶
type MiddlewareOption func(c *middlewareConfig)
func WithIsAuthenticationRequired ¶
func WithIsAuthenticationRequired(isAuthenticationRequired func(r *http.Request) bool) MiddlewareOption
Click to show internal directories.
Click to hide internal directories.