Documentation ¶
Index ¶
- func ExtractUserPass(auth string) (user, pass string, found bool, err error)
- func New(options ...func(handler *Handler) error) (defs.Middleware, error)
- func WithAuthenticator(auth Authenticator) func(h *Handler) error
- func WithLogLevel(level slog.Level) func(h *Handler) error
- func WithLogger(log *slog.Logger) func(h *Handler) error
- func WithRealm(realm string) func(h *Handler) error
- func WithRedirect(redirect string) func(h *Handler) error
- type Authenticator
- type Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractUserPass ¶
ExtractUserPass extracts the username and the password out of the given header value for Authorization. It signalizes if the desired information exists or en error, when the auth string is unprocessable.
func New ¶
func New(options ...func(handler *Handler) error) (defs.Middleware, error)
New generates a new basic authentication middleware.
func WithAuthenticator ¶
func WithAuthenticator(auth Authenticator) func(h *Handler) error
WithAuthenticator sets the Authenticator to use.
func WithLogLevel ¶
WithLogLevel configures the log level to use with the logger.
func WithLogger ¶
WithLogger configures the logger to use.
func WithRedirect ¶
Types ¶
type Authenticator ¶
type Authenticator interface { // Authenticate checks, if a given username and password are allowed // credentials Authenticate(username, password string) (bool, error) }
Authenticator is an interface the basic auth handler uses to check if the given credentials match an allowed entry.
Click to show internal directories.
Click to hide internal directories.