Skip to content

feat(embedded): add password support to the signup flow - #1139

Merged
pmathew92 merged 4 commits into
v5_developmentfrom
feat/embedded_signup_password
Nov 23, 2026
Merged

pmathew92 merged 4 commits into
v5_developmentfrom
feat/embedded_signup_password

Conversation

@pmathew92

@pmathew92 pmathew92 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Changes

Adds password support to the embedded signup flow, following the server's /e/authorize schemas.

⚠️ Breaking changes

These are intentional and land in a beta release. They will be called out in the release notes.

  • NextAction.ConfirmSignup changes from a data object to a data class with a password: SignupPassword? property. Code that uses the object itself, such as NextAction.ConfirmSignup -> in a when, and Java's INSTANCE, no longer compiles. is NextAction.ConfirmSignup still works.

How the flow changes

  • The signup action announces whether the connection collects a password (authentication_methods.password.required). The SDK reports it as Signup.passwordRequirement and keeps it with the session.

  • Once the identifiers are verified, the signup:confirm action carries password_complexity_options. ConfirmSignup.password is null when no password is collected. Otherwise it holds required (carried over from the signup action) and the advisory complexity (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 recoverable InsufficientAuthorization reasons that keep the flow open.

  • access_denied with too_many_resend_attempts is now a terminal TooManyResendAttempts error.

  • 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

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 07691e66-0eb0-47be-915e-31b0c1e01000

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pmathew92
pmathew92 marked this pull request as ready for review November 13, 2026 05:08
@pmathew92
pmathew92 requested a review from a team as a code owner November 13, 2026 05:08
@pmathew92 pmathew92 changed the title feat(embedded): add password support to the signup flow [non-main] feat(embedded): add password support to the signup flow Nov 13, 2026
else -> announced ?: transactionState?.passwordRequirement
}
val actions = failure.nextActions.map { action ->
if (action is NextAction.ConfirmSignup) action.withRequired(requirement == CredentialRequirement.REQUIRED) else action

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.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ConfirmSignup.password is non-null only when the server sends password_complexity_options. withRequired only corrects the required flag on a password that already exists. The server always sends the options when the connection collects a password, so this case shouldn't occur.

return when ((password as? Map<*, *>)?.get(REQUIRED_KEY) as? Boolean) {
true -> CredentialRequirement.REQUIRED
false -> CredentialRequirement.OPTIONAL
null -> {

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.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Password entry is optional. If its present it will have a required property as per the specs. the null is added as a safe check handling

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": {} } }"""

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.

Nit: NEXT_SIGNUP_EMAIL_PASSWORD_NO_REQUIRED isn't used anywhere. Use it in a client test or remove it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed

val actions = failure.nextActions.map { action ->
if (action is NextAction.ConfirmSignup) action.withRequired(requirement == CredentialRequirement.REQUIRED) else action
}
transactionState = EmbeddedAuthState(session, requirement)

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.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

PKCE is a different PR . This conflict is expected and will be resolved when the corresponding PRs will be merged

*/
public data object ConfirmSignup : NextAction {
@ConsistentCopyVisibility
public data class ConfirmSignup internal constructor(

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.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, Will be called out in the release note. As this is a beta releases breaking changes are expected to occur

terminalStep(EmbeddedCapability.CONFIRM_SIGNUP)
@JvmOverloads
public fun confirmSignup(password: String? = null): Request<Credentials, EmbeddedAuthException> {
val sentPassword = password?.takeIf { it.isNotEmpty() }

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.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We don't do any local validation on the SDK. Will update the doc accordingly

* [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

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.

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.

@pmathew92 pmathew92 Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

PasswordLeaked was added as part of the password signin flow . The password signup changes don't have that error added and hence not added as part of the examples for the same

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

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.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TooManyResendAttempts is not specific to Signup but when a user tries to challenge an identifier multiple times. Will add the doc for the same in the authorize.md file

override fun onFailure(error: EmbeddedAuthException) {
onStepFailure(error)
callback.onFailure(error)
callback.onFailure(onStepFailure(error))

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.

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.

@pmathew92 pmathew92 Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

await evnetually calls the callback APIs internally .Didn't add a separate specific suite because of that

* 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() }

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.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a sample app change and added intetionally for dev purpose

@NandanPrabhu
NandanPrabhu self-requested a review November 17, 2026 10:53
utkrishtsahu
utkrishtsahu previously approved these changes Nov 18, 2026
private fun NextAction.ConfirmSignup.withRequired(required: Boolean): NextAction.ConfirmSignup =
NextAction.ConfirmSignup(password?.let { SignupPassword(required, it.complexity) })

private fun EmbeddedAuthException.withNextActions(

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.

lets have this function as part of EmbeddedAuthException extension

NandanPrabhu
NandanPrabhu previously approved these changes Nov 23, 2026
@pmathew92
pmathew92 dismissed stale reviews from NandanPrabhu and utkrishtsahu via fa9cb7c November 23, 2026 07:12
@pmathew92
pmathew92 merged commit 4e4eeb3 into v5_development Nov 23, 2026
7 checks passed
@pmathew92
pmathew92 deleted the feat/embedded_signup_password branch November 23, 2026 09:29
@pmathew92 pmathew92 mentioned this pull request Nov 24, 2026
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.

3 participants