Documentation
¶
Overview ¶
Package basicauth implements the basic auth functionality.
Index ¶
- Variables
- 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 ¶
var ErrNilOption = errors.New("option cannot be nil")
ErrNilOption is returned when an option is nil.
var ErrNoAuthenticator = errors.New("no authenticator configured")
ErrNoAuthenticator is returned when there is no authenticator configured.
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 ¶
WithRedirect sets the redirect address to use.
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package htpasswdauth implements the basic auth functionality using a htpasswd file.
|
Package htpasswdauth implements the basic auth functionality using a htpasswd file. |
|
Package mapauth implements the basic auth functionality using a user-pass-map.
|
Package mapauth implements the basic auth functionality using a user-pass-map. |