Skip to content

caddyauth: Support third-party http.authentication.hashes modules - #8063

Open
hsdfat wants to merge 2 commits into
caddyserver:masterfrom
hsdfat:pluggable-auth-hashes
Open

hsdfat wants to merge 2 commits into
caddyserver:masterfrom
hsdfat:pluggable-auth-hashes

Conversation

@hsdfat

@hsdfat hsdfat commented Sep 25, 2026

Copy link
Copy Markdown

Closes #6670

basic_auth and caddy hash-password only accepted bcrypt and argon2id, even though the http.authentication.hashes namespace is documented as pluggable. Any other algorithm name is now looked up among the installed hash modules via caddy.GetModules.

  • basic_auth <name>: the module must implement Comparer; the adapted JSON is "hash": {"algorithm": "<name>"} (unchanged for bcrypt/argon2id).
  • hash-password --algorithm <name>: bcrypt/argon2id keep their dedicated flags; other modules are provisioned and must implement Hasher.
  • Unknown names now report the installed algorithms, e.g. unrecognized hash algorithm: nope (available: argon2id, bcrypt).

Tests register a dummy hash module and cover Caddyfile adaptation, provisioning/comparison through the module, the hash-password command, and the error cases (unknown name, compare-only module used with hash-password).

Assistance Disclosure

I used AI assistants (Claude, OpenAI models) while writing and reviewing this change; I verified the behaviour and tests myself.

basic_auth and hash-password only accepted the built-in bcrypt and
argon2id algorithms, even though the http.authentication.hashes
namespace is documented as extensible. Look up any other algorithm
name among the installed hash modules instead, and list the available
ones when the name is not recognized.

The built-in algorithms keep their own hash-password flags; other
modules are provisioned and must implement Hasher to generate hashes.

Closes caddyserver#6670
@CLAassistant

CLAassistant commented Sep 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread modules/caddyhttp/caddyauth/command.go Outdated
@steadytao

Copy link
Copy Markdown
Member

Also. You must sign the CLA.

hash-password printed module hashes as raw bytes, but basic_auth
base64-decodes any password that isn't in Modular Crypt Format, so the
output couldn't be used as-is. Encode non-MCF hashes as base64 and add
a round-trip test that provisions HTTPBasicAuth with the command output.
@hsdfat

hsdfat commented Sep 26, 2026

Copy link
Copy Markdown
Author

Thanks, fixed in 7deb2fd. hash-password now base64-encodes a module's hash unless it's in Modular Crypt Format (starts with $), which matches how HTTPBasicAuth.Provision decodes account passwords. TestHashPasswordCommandRoundTrip runs the command for a non-MCF module, an MCF module, bcrypt and argon2id, and provisions HTTPBasicAuth with each output. The non-MCF case fails without the fix.

I'll sign the CLA.

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must sign the CLA but otherwise LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: support modules implementing http.authentication.hashes

3 participants