Skip to content

Add support for validating passwords against the password policy in auth #7514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Aug 7, 2023

Conversation

ch5zzy
Copy link
Contributor

@ch5zzy ch5zzy commented Aug 1, 2023

Add a validatePassword method that allows developers to validate passwords against the password policy configured for the project or tenant. This method returns a status object, PasswordValidationStatus, that can be used to display the requirements and check whether each was met.

ch5zzy added 19 commits June 26, 2023 12:52
* Add password policy endpoint in auth to allow fetching the password policy for the project/tenant
* Add PasswordPolicy and PasswordValidationStatus public types

* Add public types to docs and implement AuthInternal password policy cache

* Add schema version mismatch error and tests

* Update error code in fetch test and add TODO for schema version handling
* Add password does not meet requirements error and update policy in sign up flow when error is received
* Add validatePassword method with implementation TODO
* Define internal password policy typings
* Define PasswordPolicyImpl

* Add PasswordPolicyCustomStrengthOptions internal typing
* Update Auth to use PasswordPolicyImpl for validation

* Rename _getPasswordPolicy to _getPasswordPolicyInternal
…tch API proposal (#7456)

* Implement validatePassword

* Fix allowedNonAlphanumericCharacters typing to match API proposal
… does not meet the backend requirements (#7434)

* Update confirmPasswordReset to handle updating the cache upon password requirements error

* Refactor existing test cases to clean up code style
…ot meet the backend requirements (#7435)

* Update signInWithEmailAndPassword to handle updating password policy cache

* Remove await on calls recachePasswordPolicy

* Throw errors instead of rejecting promises
…putted to validatePassword (#7471)

* Include the character option statuses even when an empty string is inputted
* Update auth demo to include a section for password validation
…7476)

* Add enforcementState and forceUpgradeOnSignin to PasswordPolicy type
…icy response (#7485)

* Store an empty string if no non-alphanumeric characters are included in the password policy response
…a password (#7487)

* Update auth demo with new fields and move validation into auth flow sections
* Use a default minimum password length of 6 when it is undefined in the password policy response as a temporary solution until the backend is updated
* Add password policy integration tests and helper method for generating valid passwords

* Update prodbackend tests to include password policy tests

* Update README with password policy integration testing instructions
* Update handling of password policy recaching in sign up to not conflict with handling of other errors like missing reCAPTCHA token
@changeset-bot
Copy link

changeset-bot bot commented Aug 1, 2023

🦋 Changeset detected

Latest commit: fbd258c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/auth Minor
firebase Minor
@firebase/auth-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ch5zzy ch5zzy requested a review from Xiaoshouzi-gh August 1, 2023 21:14
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 1, 2023

Size Report 1

Affected Products

  • @firebase/auth

    TypeBase (0038e11)Merge (502e0ac)Diff
    browser171 kB177 kB+5.92 kB (+3.5%)
    cordova198 kB206 kB+7.18 kB (+3.6%)
    esm5223 kB231 kB+7.18 kB (+3.2%)
    main168 kB175 kB+7.38 kB (+4.4%)
    module171 kB177 kB+5.92 kB (+3.5%)
    react-native182 kB189 kB+7.41 kB (+4.1%)
  • @firebase/auth/cordova

    TypeBase (0038e11)Merge (502e0ac)Diff
    browser198 kB206 kB+7.18 kB (+3.6%)
    module198 kB206 kB+7.18 kB (+3.6%)
  • @firebase/auth/internal

    TypeBase (0038e11)Merge (502e0ac)Diff
    browser182 kB188 kB+5.92 kB (+3.3%)
    esm5237 kB244 kB+7.18 kB (+3.0%)
    main204 kB211 kB+7.42 kB (+3.6%)
    module182 kB188 kB+5.92 kB (+3.3%)
  • bundle

    TypeBase (0038e11)Merge (502e0ac)Diff
    auth (Anonymous)68.8 kB72.6 kB+3.83 kB (+5.6%)
    auth (EmailAndPassword)75.9 kB79.9 kB+4.03 kB (+5.3%)
    auth (GoogleFBTwitterGitHubPopup)95.4 kB99.2 kB+3.83 kB (+4.0%)
    auth (GooglePopup)92.7 kB96.5 kB+3.83 kB (+4.1%)
    auth (GoogleRedirect)92.9 kB96.7 kB+3.83 kB (+4.1%)
    auth (Phone)79.1 kB82.9 kB+3.83 kB (+4.8%)
  • firebase

    TypeBase (0038e11)Merge (502e0ac)Diff
    firebase-auth-compat.js132 kB136 kB+4.19 kB (+3.2%)
    firebase-auth-cordova.js169 kB174 kB+5.66 kB (+3.4%)
    firebase-auth.js142 kB147 kB+4.51 kB (+3.2%)
    firebase-compat.js774 kB778 kB+4.19 kB (+0.5%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/khc813McVW.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 1, 2023

Size Analysis Report 1

This report is too large (381,042 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/GmmRhVDPBh.html

@ch5zzy ch5zzy marked this pull request as ready for review August 1, 2023 22:52
@ch5zzy ch5zzy requested review from a team and egilmorez as code owners August 1, 2023 22:52
@prameshj
Copy link
Contributor

prameshj commented Aug 3, 2023

@DellaBitta Can you help review this? Thanks!

Copy link
Contributor

@DellaBitta DellaBitta left a comment

Choose a reason for hiding this comment

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

Half way through, but I will continue in the morning. Some comments so far.

@ch5zzy ch5zzy requested a review from DellaBitta August 7, 2023 16:32
@ch5zzy ch5zzy merged commit c9e2b0b into master Aug 7, 2023
@ch5zzy ch5zzy deleted the password-policy branch August 7, 2023 18:54
@google-oss-bot google-oss-bot mentioned this pull request Aug 15, 2023
@firebase firebase locked and limited conversation to collaborators Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants