aralez-basic-auth is an htpasswd-based HTTP Basic authentication plugin designed for the aralez reverse proxy.
It provides basic authentication by reading credentials from standard .htpasswd files, featuring real-time hot-reloading for file updates without requiring proxy restarts.
htpasswdFile Support: Reads and parses standardusername:hashformatted htpasswd files, automatically skipping comments and empty lines.bcryptPassword Verification: Validates passwords usingbcrypthashing. Automatically normalizes$2y$hash prefixes to$2b$for compatibility.- Real-Time Hot-Reloading: Utilizes
notifyfile watching to detect changes in the.htpasswdfile asynchronously and update credentials in memory dynamically. - Efficient Resource Management: Caches loaded credential data and watcher tasks using
Weakreferences to prevent duplicate file watchers for the same file path. - Plug & Play: Integrates seamlessly via the
inventoryplugin system under the plugin name"htpasswd".
- Access Validation: The plugin checks the incoming request for an
Authorizationheader using theBasicscheme. - Credential Extraction: Decodes the Base64 payload from the header to extract the username and password.
- Password Verification: Looks up the user's password hash from memory and verifies the provided password using
bcrypt. - Access Grant or Challenge: If verification succeeds, the request is proxied directly to the backend. If authentication fails or the header is missing, the plugin returns a
401 Unauthorizedresponse with theWWW-Authenticate: Basic realm="Access Required"header.
You can configure this plugin using your application's configuration file (compatible with noyalib / YAML structures) by specifying the htpasswd auth plugin type.
| Key | Type | Required | Description |
|---|---|---|---|
type |
String | Required | Must be set to "htpasswd" to select this plugin. |
data |
String | Required | The file path to the .htpasswd file (e.g., "/etc/aralez/.htpasswd"). |
authorization:
type: "htpasswd"
data: "/etc/aralez/.htpasswd"Licensed under the Apache License, Version 2.0.