Documentation
¶
Overview ¶
Authentication package provides a set of authentication backends for your application.
Currently, it supports [basic.Basic], [file.File] and [oidc.OIDC].
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UserForRequest ¶
UserForRequest retrieves the authenticated user from the request context and returns it in username. present is true if authentication informations are found. A value of false indicates the request has not been processed by authentication middleware.
Types ¶
type AuthStatus ¶
type AuthStatus struct {
Authenticated bool // Indicates if the user is authenticated
User string // The authenticated user
Error error // Any error that occurred during authentication
}
AuthStatus contains authentication information for the current context.
func AuthForRequest ¶
func AuthForRequest(r *http.Request) (AuthStatus, bool)
AuthForRequest retrieves the authentication status from the request context.
type AuthStatusKeyType ¶
type AuthStatusKeyType string
var AuthStatusKey AuthStatusKeyType = "AuthStatus"
type Authentication ¶
type Authentication interface {
// AuthMiddleware returns a middleware that will be used to authenticate the
AuthMiddleware(next http.Handler) http.Handler
}
Authentication must be implemented by the authentication backend If you want to implement your own authentication backend, you need to implement this interface.
type CallbackHandler ¶
type CallbackHandler interface {
// CallbackHandler returns handler associated to the pattern, of the form
// "GET /path" or "POST /path".
CallbackHandler(h http.Handler) (pattern string, handler http.Handler)
}
CallbackHandler is an interface for authentications that need to handle a callback from an external service (like OIDC).
type CustomLoginHandler ¶
type CustomLoginHandler interface {
// LoginHandler returns handler h associated to "GET path" pattern.
// If skipForm is true, the login form is not displayed and user redirected
// to path
LoginHandler() (path string, skipForm bool, h http.Handler)
}
CustomLoginHandler is an interface for authentications that needs to handle the login form.
type CustomLogout ¶ added in v0.9.7
type CustomLogout interface {
// LoginHandler returns handler h associated to "GET path" pattern.
// If skipForm is true, the login form is not displayed and user redirected
// to path
LogoutURL() (url string)
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Basic authentication provides a simple username/password authentication passed in authentication header.
|
Basic authentication provides a simple username/password authentication passed in authentication header. |
|
File is an authentication that takes users from a yaml file Example :
|
File is an authentication that takes users from a yaml file Example : |
|
package oidc provides OIDC authentication to APIWS.
|
package oidc provides OIDC authentication to APIWS. |