Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
| val minLength = (options[MIN_LENGTH_KEY] as? Number)?.toWholeInt()?.takeIf { it >= 1 } | ||
| if (minLength == null) { | ||
| Log.w(TAG, "Ignoring signup password: required field \"$MIN_LENGTH_KEY\" was missing or invalid.") | ||
| return null |
There was a problem hiding this comment.
If min_length is missing or bad, we drop the whole password object. On a connection that requires a password, the app then shows no field and the server keeps returning password_required with the same ConfirmSignup(null), so the user can't finish. Can we fall back to a default complexity (e.g. minLength = 1, no types) when the connection collects a password, instead of returning null?
| else -> announced ?: transactionState?.passwordRequirement | ||
| } | ||
| val actions = failure.nextActions.map { action -> | ||
| if (action is NextAction.ConfirmSignup) action.withRequired(requirement == CredentialRequirement.REQUIRED) else action |
There was a problem hiding this comment.
Related to the mapper comment: if requirement is REQUIRED but password is null here, withRequired keeps it null and the app can't recover. Maybe build a SignupPassword in that case?
| return when ((password as? Map<*, *>)?.get(REQUIRED_KEY) as? Boolean) { | ||
| true -> CredentialRequirement.REQUIRED | ||
| false -> CredentialRequirement.OPTIONAL | ||
| null -> { |
There was a problem hiding this comment.
A password entry without a boolean required still means the connection collects a password. Would OPTIONAL be safer than NONE here? NONE hides the field.
| const val NEXT_SIGNUP_EMAIL_NON_BOOLEAN_REQUIRED = """{ "action": "action:signup:v1", "identifiers": { "email": { "required": "true" }, "phone_number": { "required": false } } }""" | ||
| const val NEXT_SIGNUP_EMAIL_PASSWORD_REQUIRED = """{ "action": "action:signup:v1", "identifiers": { "email": { "required": true } }, "authentication_methods": { "password": { "required": true } } }""" | ||
| const val NEXT_SIGNUP_EMAIL_PASSWORD_OPTIONAL = """{ "action": "action:signup:v1", "identifiers": { "email": { "required": true } }, "authentication_methods": { "password": { "required": false } } }""" | ||
| const val NEXT_SIGNUP_EMAIL_PASSWORD_NO_REQUIRED = """{ "action": "action:signup:v1", "identifiers": { "email": { "required": true } }, "authentication_methods": { "password": {} } }""" |
There was a problem hiding this comment.
Nit: NEXT_SIGNUP_EMAIL_PASSWORD_NO_REQUIRED isn't used anywhere. Use it in a client test or remove it?
| val actions = failure.nextActions.map { action -> | ||
| if (action is NextAction.ConfirmSignup) action.withRequired(requirement == CredentialRequirement.REQUIRED) else action | ||
| } | ||
| transactionState = EmbeddedAuthState(session, requirement) |
There was a problem hiding this comment.
This conflicts with the PKCE PR (#1141): there EmbeddedAuthState is (codeVerifier, authSession?) and the session is rotated with copy(authSession = ...). A fresh EmbeddedAuthState(session, requirement) here would drop the verifier once both land, so whichever merges second should use transactionState?.copy(authSession = session, passwordRequirement = requirement).
| */ | ||
| public data object ConfirmSignup : NextAction { | ||
| @ConsistentCopyVisibility | ||
| public data class ConfirmSignup internal constructor( |
There was a problem hiding this comment.
ConfirmSignup was a data object in 5.0.0-beta.3, so this breaks NextAction.ConfirmSignup -> branches and Java's INSTANCE. The new TooManyResendAttempts and Reason values also break exhaustive whens. Please call these out as breaking in the PR description and release notes.
| terminalStep(EmbeddedCapability.CONFIRM_SIGNUP) | ||
| @JvmOverloads | ||
| public fun confirmSignup(password: String? = null): Request<Credentials, EmbeddedAuthException> { | ||
| val sentPassword = password?.takeIf { it.isNotEmpty() } |
There was a problem hiding this comment.
The spec caps this password at 2048 characters. A longer one gets a 400, which updateSessionFromFailure treats as terminal and clears the session, so the user has to redo the OTP. Reject it locally without touching the session, or document the limit next to the empty-string rule.
| * [EmbeddedAuthError.InsufficientAuthorization.Reason.PASSWORD_NOT_ACCEPTED], and a password the | ||
| * connection's policy rejects with [EmbeddedAuthError.InsufficientAuthorization.Reason.INVALID_PASSWORD]. | ||
| * Each keeps the flow open, so call again with the right input. | ||
| * If the account can't be created, the request completes with the terminal |
There was a problem hiding this comment.
The design lists password_leaked (terminal PasswordLeaked) among the password sign-up errors, but it isn't mentioned here or in signup.md. Worth documenting if the server can return it on confirm.
| public data object TooManyWrongOtpAttempts : EmbeddedAuthError | ||
|
|
||
| /** Terminal: the limit of verification codes sent to this identifier was reached. Restart the flow. */ | ||
| public data object TooManyResendAttempts : EmbeddedAuthError |
There was a problem hiding this comment.
TooManyResendAttempts is missing from the terminal-errors list in examples/embedded-auth/authorize.md and from the error handling in signup.md. Can we add it to both so the examples match the new public case?
| override fun onFailure(error: EmbeddedAuthException) { | ||
| onStepFailure(error) | ||
| callback.onFailure(error) | ||
| callback.onFailure(onStepFailure(error)) |
There was a problem hiding this comment.
The corrected required flag only reaches callers through the exception built here, but the client tests only use await(). Please add a start(callback) test so a revert to callback.onFailure(error) can't pass.
| * Terminal step: creates the account and yields credentials, or continues if MFA is required or the | ||
| * password is rejected. Pass the password only when the confirm action offers one. | ||
| */ | ||
| fun confirmSignup(password: String? = null): Unit = runTerminalStep { client.confirmSignup(password).await() } |
There was a problem hiding this comment.
The sample enables BODY logging on DefaultClient (line 35), so this signup password and the token response end up in logcat in plain text. Gate logging on BuildConfig.DEBUG or turn it off.
Changes
Adds password support to the embedded signup flow, following the server's
/e/authorizeschemas.How the flow changes
The
signupaction announces whether the connection collects a password (authentication_methods.password.required). The SDK reports it asSignup.passwordRequirementand keeps it with the session.Once the identifiers are verified, the
signup:confirmaction carriespassword_complexity_options.ConfirmSignup.passwordisnullwhen no password is collected. Otherwise it holdsrequired(carried over from the signup action) and the advisorycomplexity(minimum length and the character types that are all required).confirmSignup(password)sends the password as given, and an empty string counts as none. The SDK does not validate it, and the server decides. A missing required password, a password sent to a connection that collects none, and a rejected password come back as recoverableInsufficientAuthorizationreasons that keep the flow open.access_deniedwithtoo_many_resend_attemptsis now a terminalTooManyResendAttemptserror.This change adds unit test coverage
This change adds integration test coverage
This change has been tested on the latest version of the platform/language or why not
Checklist
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors