Repository navigation
Fix password pwned policy so enabled records and users/sessions block - #13818
Merged
Merged
Conversation
The three policy options did not mean what they say. `enabled` alone rejected breached passwords on sign-up and password changes, nothing was looked up on sign-in unless `sessions` was set, and `users` refused a sign-in rather than a sign-up. Now each option has one job: - `enabled` turns the integration on. Every password Appwrite sees on sign-up, sign-in, password change, recovery or anonymous conversion is looked up and the outcome recorded on the user as `passwordPwned`. On its own it never rejects anything. - `users` rejects a breached password when a user signs up or sets a new password (`password_pwned`, 400). - `sessions` refuses a sign-in with a breached password until it is reset (`user_password_reset_required`, 412). Endpoint and model descriptions follow, and the e2e suite asserts the new contract: `enabled=false` switches both blocking options off, and neither blocking option leaks onto the other surface. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Contributor
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The
password-pwnedproject policy has three options, but the implementation did not match their names:enabledpasswordPwned. Never rejects on its ownsessionsuser_password_reset_required, 412)userssessionswas also onpassword_pwned, 400)enabled=falseswitches the integration off entirely, so neither blocking option has any effect and the flag staysnull.Changes
app/controllers/api/account.php: sign-in looks the password up whenever the policy is enabled and only refuses onsessions; account create, password update, recovery (link and OTP) and anonymous email/phone conversion only reject onusers.Users/Http/Users/Create.php,Users/Http/Users/Password/Update.php: sameusersgate on the server API.Policies/PasswordPwned/Update.php,Model/PolicyPasswordPwned.php: descriptions say what each option does now. No request or response shape changes.tests/e2e/Services/Project/PoliciesPasswordPwnedIntegrationTest.php: asserts the new contract per surface, thatenabled=falsedisables the blocking options, and thatusersnever touches sign-in whilesessionsnever touches sign-up.Notes for reviewers
userstogether with sign-up. Without that, a project blocking breached sign-ups could still pick a breached password at reset time.enabledis on by default, sign-in now performs a lookup for every project unless the policy is disabled. With_APP_PWNED_PASSWORDS_DSNset tohibp://orappwrite://, an unreachable breach service surfacesgeneral_pwned_passwords_unavailable(503) on sign-in the same way it already does on sign-up. Recording best-effort during an outage while still failing closed when blocking would be a small follow-up if we want it.Test Plan
composer linton every touched file: passedtests/tools/rector.php) on the changed test: cleanvendor/bin/phpunit tests/unit/Auth/Validator: 61 tests passeddocker compose exec appwrite test tests/e2e/Services/Project/PoliciesPasswordPwnedIntegrationTest.phpruns in CI with_APP_PWNED_PASSWORDS_DSN=mock://localhostRelated PRs and Issues
f559b4a55fand reduced to three options in4f2e203327Checklist
🤖 Generated with Claude Code