logto-io / logto

🧑‍🚀 The better identity infrastructure for developers and the open-source alternative to Auth0.
https://logto.io
Mozilla Public License 2.0
8.15k stars 395 forks source link

feat(core,schemas): implement the username password registration flow #6249

Closed simeng-li closed 1 month ago

simeng-li commented 1 month ago

Summary

This PR implements the username+password registration flow.

New NewPasswordIdentifyVerification verification record.

We defined a new NewPasswordIdentifyVerification verification record class in this PR. It represents a verification record that is used to return a valid new password+identifier for new user registration use. This verification record will verify the uniqueness of the given identifier and validate the password against the password policy checker.

New POST /verifications/new-password-identity verification endpoint

This endpoint will create and verify a new password identity. A verification record will be stored in the interaction storage after a successful verification.

New validatePassword method in the ProfileValidator

This method will validate the new given password against the password policy checker. Throws an error if any violation is found.

New getPasswordPolicyChecker method in the SignInExperienceValidator

As the PasswordPolicyChecker relys on the SIE settings to generate a proper policy checker. We add an async method here to fetch and create a new PasswordPolicyChecker instance for password validation use.

Testing

Checklist

github-actions[bot] commented 1 month ago

COMPARE TO master

Total Size Diff :warning: :chart_with_upwards_trend: +17.98 KB

Diff by File |Name|Diff| |---|---| |packages/core/src/libraries/user.utils.ts|:chart_with_upwards_trend: +8 Bytes| |packages/core/src/routes/experience/classes/experience-interaction.ts|:chart_with_upwards_trend: +270 Bytes| |packages/core/src/routes/experience/classes/utils.test.ts|:chart_with_upwards_trend: +1.28 KB| |packages/core/src/routes/experience/classes/utils.ts|:chart_with_upwards_trend: +1.11 KB| |packages/core/src/routes/experience/classes/validators/profile-validator.ts|:chart_with_upwards_trend: +614 Bytes| |packages/core/src/routes/experience/classes/validators/sign-in-experience-validator.test.ts|:chart_with_upwards_trend: +384 Bytes| |packages/core/src/routes/experience/classes/validators/sign-in-experience-validator.ts|:chart_with_upwards_trend: +776 Bytes| |packages/core/src/routes/experience/classes/verifications/code-verification.ts|:chart_with_upwards_trend: +15 Bytes| |packages/core/src/routes/experience/classes/verifications/index.ts|:chart_with_upwards_trend: +457 Bytes| |packages/core/src/routes/experience/classes/verifications/new-password-identity-verification.ts|:chart_with_upwards_trend: +4.93 KB| |packages/core/src/routes/experience/classes/verifications/password-verification.ts|:chart_with_upwards_trend: +14 Bytes| |packages/core/src/routes/experience/index.ts|:chart_with_upwards_trend: +170 Bytes| |packages/core/src/routes/experience/verification-routes/new-password-identity-verification.ts|:chart_with_upwards_trend: +1.76 KB| |packages/integration-tests/src/client/experience/index.ts|:chart_with_upwards_trend: +379 Bytes| |packages/integration-tests/src/helpers/experience/index.ts|:chart_with_upwards_trend: +634 Bytes| |packages/integration-tests/src/tests/api/experience-api/register-interaction/username-password.test.ts|:chart_with_upwards_trend: +1.26 KB| |packages/integration-tests/src/tests/api/experience-api/verifications/new-password-identity-verification.test.ts|:chart_with_upwards_trend: +3.31 KB| |packages/schemas/src/types/interactions.ts|:chart_with_upwards_trend: +780 Bytes|