Documentation
¶
Overview ¶
Package auth provides HTTP Basic authentication for the admin console and API. Credentials are a set of username + bcrypt password-hash pairs loaded from config and the JOEI_CONSOLE_AUTH_USERS environment variable. With no users configured the set is "locked" (fail-closed): the middleware serves 503 and never reaches the wrapped handler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
Users is a validated set of credentials. An empty set is the locked state.
func NewUsers ¶
NewUsers builds the credential set from config-file users and the semicolon-separated JOEI_CONSOLE_AUTH_USERS env value ("username:hash;username:hash"). Whitespace around entries is trimmed. Env entries override file entries with the same username. Every username must be non-empty and every hash must be a valid bcrypt hash, else an error is returned. An empty result is valid and yields the locked state.
func (*Users) Middleware ¶
Middleware wraps h with HTTP Basic authentication.
- Locked (no users configured): serves 503 and never calls h.
- Missing or invalid credentials: serves 401 with a Basic challenge.
- Valid credentials: stores the username in the request context (see UserFromContext) and calls h.