Reject passwords containing user's personal info - #910
Open
iamtanuj18 wants to merge 13 commits into
Open
Conversation
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.
Fixes #902
Currently
checkPasswordStrengthonly checks the password itself, so apassword like
Firstnamelastname2026!passes all requirements eventhough it's tied to who the user is. This PR extends the check to
reject passwords containing the user's name, email local part, or DOB
year.
Approach
checkPasswordStrengthgets an optionalcontextparam carryingfirstName, middleName, lastName, email, and dob (each optional).
tokens of at least 4 characters retained. Email uses the part before
@(the domain isn't flagged as PII). DOB uses the 4-digit year.(case-insensitive), the check fails with a
PersonalInfofieldnaming the specific matched token.
Where it's wired
Server-side (authoritative):
AuthController.registerParticipant- name, email, dob from bodyAuthController.registerUser- name and email from bodyAuthController.registerInitialUser- only email (setup form doesn'tcollect names)
UsersController.resetPassword- name and email from the token'suser relation, plus a
ParticipantProfilelookup for dob(participants only)
Client-side (submit-time UX):
user-client/Register.tsx- pulls all four via RHFgetValues()admin-client/setup/index.tsx- pulls emailThe two reset-password forms don't have PII fields on them, so
client-side is a no-op there and the server handles rejection.
Tests
PasswordStrength.test.ts- unit tests (backwards compat, each PIIfield, case-insensitivity, the 4-character filter, multi-word names,
empty context, error message content, multiple simultaneous failures)
ResetPassword.test.ts- integration case for a PII password rejectedend-to-end through the reset flow
seed.ts-PASSWORD_RESET_USERplaceholder firstName/lastNamechanged to values that don't collide with common test passwords
Scope
createAdmin.ts) isn't touchedhere; strength enforcement for that path is handled by Enforce password strength check in createAdmin.ts #908.
so the setup admin gets an email-only check. Adding names to the
setup form would be a separate ticket.