Skip to content

feat: add custom password policy deny lists - #14499

Merged
Meldiron merged 4 commits into
appwrite:mainfrom
Indra55:feat/custom-password-deny-lists
Oct 18, 2026
Merged

Meldiron merged 4 commits into
appwrite:mainfrom
Indra55:feat/custom-password-deny-lists

Conversation

@Indra55

@Indra55 Indra55 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds an optional denyList string array to updatePasswordDictionaryPolicy() and updatePasswordPersonalDataPolicy() so developers can block passwords and terms specific to their application.

  • Dictionary policy: blocks exact, case-sensitive matches alongside the existing common-password dictionary. For example, a deny-list entry of AcmeDefault123! blocks that password, but allows MyAcmeDefault123!.
  • Personal-data policy: blocks passwords containing custom terms using the validator's existing case-insensitive matching. For example, appwrite blocks MyAppWrite2026!.

Each list applies only while its policy is enabled. Omitting denyList or passing null preserves the current list, an array replaces it, and [] clears it. Both policy GET and list responses include the configured values.

Validation applies when setting passwords through account creation, password updates, first-password setup, user administration, and recovery. Existing passwords still work for sign-in and password confirmation. Custom deny lists are not applied to imported password hashes.

A few details worth highlighting:

  • Recovery now also checks the recovered user's ID, name, email, and phone. This closes an existing gap but expands behavior beyond adding custom deny lists, including when the custom list is empty.
  • Each list accepts up to 100 entries of 1–256 characters. The combined project authentication configuration remains subject to its existing 16,384-character storage limit, so some lists within the individual limits can still be rejected.
  • Entries are stored without trimming or deduplication. Personal-data matching follows the existing strtolower() behavior rather than Unicode case folding.

Test Plan

Added unit tests for exact and substring matching, case handling, disabled policies, empty lists, and existing validator behavior.

Added E2E and integration coverage for policy persistence, replacement and clearing, GET/list responses, legacy routes, input validation, scopes, storage limits, and project isolation. Password-flow tests cover creation, updates, first-password setup, recovery, existing-password confirmation, and imported hashes.

Latest local checks:

  • 33 unit tests and 84 assertions passed. PHPUnit reported a cleanup warning because the local PHP runtime lacks Swoole\Timer.
  • Pint and git diff --check passed.
  • E2E was not rerun during the latest review because the API container was stopped.

To run the focused tests with the development stack running:

docker compose exec -T appwrite test tests/unit/Auth/Validator --filter='PasswordDictionary|PersonalData'
docker compose exec -T appwrite test tests/e2e/Services/Project --filter='Password(Dictionary|PersonalData|DenyList)'
docker compose exec -T appwrite test tests/e2e/Services/Project --filter='test(GetPolicy|ListPolicies)'

Related PRs and Issues

Implements the two assigned custom password deny-list tasks. No linked issue.

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Endpoint metadata, response models, and recovery reference docs are updated. Generated API specs and SDK examples are not included in this PR.

@ghost

ghost commented Oct 14, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The SDK parameter locks match the newly appended optional parameters, and I found no issues in the incremental change.

Adds optional custom deny lists to the project password dictionary and personal-data policies, exposes the configured entries in policy responses, and enforces them across password-setting and recovery flows. It also documents the policy behavior and adds validator, integration, and E2E coverage. The latest commit updates the SDK parameter-order lock for the new optional denyList arguments.

Latest changes: The new commit appends denyList to the locked parameter order for both policy-update methods in the client and server SDKs.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

@Indra55 does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 11
File Change
app/config/sdks/parameters.lock.json Locks denyList after enabled for both password policy update methods.
app/controllers/api/account.php Applies the configured password policies across account password flows, including recovery.
docs/references/account/update-recovery.md; docs/references/account/update-recovery-otp.md Documents password-policy validation during both recovery methods.
src/Appwrite/Auth/Validator/PasswordDictionary.php; src/Appwrite/Auth/Validator/PersonalData.php Adds custom exact-match dictionary and case-insensitive personal-data deny-list validation.
src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Get.php; src/Appwrite/Platform/Modules/Project/Http/Project/Policies/XList.php Includes configured deny-list entries in policy GET and list responses.
src/Appwrite/Platform/Modules/Project/Http/Project/Policies/PasswordDictionary/Update.php; src/Appwrite/Platform/Modules/Project/Http/Project/Policies/PasswordPersonalData/Update.php Supports preserving, replacing, and clearing deny lists when updating the password policies.
src/Appwrite/Platform/Modules/Users/Base.php; src/Appwrite/Platform/Modules/Users/Http/Users/Create.php; src/Appwrite/Platform/Modules/Users/Http/Users/Password/Update.php Enforces the configured policies during user creation and administrative password changes.
src/Appwrite/Utopia/Response/Model/PolicyPasswordDictionary.php; src/Appwrite/Utopia/Response/Model/PolicyPasswordPersonalData.php Adds deny-list fields to the policy response models.
tests/e2e/Services/Project/PasswordDenyListBase.php; tests/e2e/Services/Project/PoliciesBase.php; tests/e2e/Services/Project/PoliciesCustomServerTest.php Covers deny-list configuration, response behavior, validation, scopes, and password flows through E2E tests.
tests/e2e/Services/Project/PoliciesPasswordDictionaryIntegrationTest.php; tests/e2e/Services/Project/PoliciesPasswordPersonalDataIntegrationTest.php Covers dictionary and personal-data policy integration behavior.
tests/unit/Auth/Validator/PasswordDictionaryTest.php; tests/unit/Auth/Validator/PersonalDataTest.php Tests deny-list matching and existing validator behavior.

Reviewed the commits since d4d79b7 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@Meldiron Meldiron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looks very good!

One open question is if we should apply rules during sign-up or sign-up, if it should be param, and if so, if we need param in more policies

@Indra55

Indra55 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Overall looks very good!

One open question is if we should apply rules during sign-up or sign-up, if it should be param, and if so, if we need param in more policies

Thanks for reviewing! Currently, the rules apply whenever a password is set or changed, including sign-up and recovery. Existing passwords still work for sign-in. Should I update this PR to make sign-in enforcement optional and add the same setting to the other relevant password policies?

@Meldiron

Copy link
Copy Markdown
Contributor

I am going forward as is. This decision is hard to make, so I am taking safe route of adding feature a bit less strict, and based on feedback, we add more configuration in future.

Mostly worrying because adding configuration here will make other password policies need the same thing.

@Meldiron
Meldiron merged commit fcd324e into appwrite:main Oct 18, 2026
63 checks passed
@ChiragAgg5k ChiragAgg5k mentioned this pull request Oct 21, 2026
6 tasks
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.

2 participants