fix(auth): default the breach service DSN to none

A server that has not been told which breach service to ask should ask
nobody, rather than call the public Have I Been Pwned API on its own:
`_APP_PWNED_PASSWORDS_DSN` now defaults to `none://localhost`. The
policy stays enabled by default per project, but it protects nothing
until an operator points the DSN at a service, which the variable
description now says first.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Matej BačoandClaude Fable 5.1 committed 2026-09-16 22:47:49 +02:00
1 parent 40ead5aa94
commit ccf4aea37f
3 files changed
+9 -7

No files matched your search

+2 -2
View File
@@ -486,9 +486,9 @@ return [
],
[
'name' => '_APP_PWNED_PASSWORDS_DSN',
'description' => "DSN of the service the password pwned project policy asks whether a password has been breached. The scheme picks the adapter.\n\nExamples:\n- Have I Been Pwned: `hibp://localhost` — the public range API, which only ever receives the first five characters of the password SHA-1 hash. No other detail is read from the DSN\n- [Appwrite Pwned](https://github.com/appwrite-labs/pwned): `appwrite://SECRET@appwrite-pwned/v1/detection` — a service you run yourself, which answers from its own copy of the Have I Been Pwned corpus, so nothing about the password leaves your network. It receives the whole password, authenticated with `SECRET` as a Bearer token, which must match the service's `APPWRITE_PWNED_SECRET`, so only point it at a service on your own network or behind TLS. The path defaults to `v1/detection` and the connection is plain HTTP unless you add `?tls=true`\n- None: `none://localhost` — reports every password as safe without asking anyone, for a server that must not or cannot reach a breach service. Projects can still enable the policy, but it protects nothing until you point the server at a real service\n- Testing: `mock://localhost` — reports a fixed list of passwords as breached without leaving the process. Refused on a production server, since it would report every real password as safe",
'description' => "DSN of the service the password pwned project policy asks whether a password has been breached. The scheme picks the adapter. Nothing is asked until you set it: the default, `none://localhost`, reports every password as safe, so the policy protects nothing until this points at a service.\n\nOptions:\n- None: `none://localhost` — the default. Reports every password as safe without asking anyone, for a server that must not or cannot reach a breach service\n- Have I Been Pwned: `hibp://localhost` — the public range API, which only ever receives the first five characters of the password SHA-1 hash. No other detail is read from the DSN\n- [Appwrite Pwned](https://github.com/appwrite-labs/pwned): `appwrite://SECRET@appwrite-pwned/v1/detection` — a service you run yourself, which answers from its own copy of the Have I Been Pwned corpus, so nothing about the password leaves your network. It receives the whole password, authenticated with `SECRET` as a Bearer token, which must match the service's `APPWRITE_PWNED_SECRET`, so only point it at a service on your own network or behind TLS. The path defaults to `v1/detection` and the connection is plain HTTP unless you add `?tls=true`\n- Testing: `mock://localhost` — reports a fixed list of passwords as breached without leaving the process. Refused on a production server, since it would report every real password as safe",
'introduction' => 'TBD',
'default' => 'hibp://localhost',
'default' => 'none://localhost',
'required' => false,
'question' => '',
'filter' => ''
+2 -1
View File
@@ -679,7 +679,8 @@ return function (Container $context): void {
}, ['user', 'store', 'proofForToken']);
$context->set('pwnedPasswords', function (Cache $cache) {
$dsn = new DSN(System::getEnv('_APP_PWNED_PASSWORDS_DSN', 'hibp://localhost'));
// Nothing is asked until an operator points this at a service
$dsn = new DSN(System::getEnv('_APP_PWNED_PASSWORDS_DSN', 'none://localhost'));
return match ($dsn->getScheme()) {
'hibp' => new PasswordPwnedHIBP($cache),
@@ -7,10 +7,11 @@ use Appwrite\Auth\Validator\PasswordPwned;
/**
* Reports every password as safe, without asking anyone.
*
* For a server that must not, or cannot, reach a breach service, such as an
* air-gapped installation. Projects can still switch the policy on, but it
* protects nothing until the server is pointed at a real service, and every
* checked user reads as clean.
* The default until an operator points `_APP_PWNED_PASSWORDS_DSN` at a
* service, and the right choice for a server that must not, or cannot, reach
* one, such as an air-gapped installation. Projects can still switch the
* policy on, but it protects nothing until the server is pointed at a real
* service, and every checked user reads as clean.
*
* DSN: `none://localhost`, no details are read.
*/