Skip to content

feat(auth): make each MFA enrollment step a real navigation destination - #2467

Merged
russellwheatley merged 1 commit into
version-10.0.0-beta05from
feat/mfa-enrollment-per-step-nav
Sep 2, 2026
Merged

feat(auth): make each MFA enrollment step a real navigation destination#2467
russellwheatley merged 1 commit into
version-10.0.0-beta05from
feat/mfa-enrollment-per-step-nav

Conversation

@demolaf

@demolaf demolaf commented Sep 1, 2026

Copy link
Copy Markdown
Member

MFA enrollment kept its four steps in local composable state, so onBackClick hand-rolled a back stack by inspecting the selected factor, and backing out of SMS enrollment discarded the phone number the user had typed. Each step is now its own destination, so system back walks them and entered data survives.

Cross-step state moves into a MfaEnrollmentFlowState holder above the NavHost, with hand-written Savers so the SMS session and selected country survive Activity recreation. A TOTP secret can't survive one — the SDK's TotpSecret is an interface with no public reconstruction path — so a lost secret is now regenerated with a fresh QR code and an explanatory message, rather than leaving the user on an opaque "No TOTP secret available" error.

  • MfaEnrollmentDestinations.kt: shared graph extension registering the four steps, plus mfaEnrollmentStartStep so a single-allowed-factor config resolves its start step at flow entry instead of auto-advancing past SelectFactor.
  • MfaEnrollmentScreen: gained step/onNavigateToStep/onNavigateBack/flowState as a required set (a partial subset throws at composition); a null step preserves today's standalone behaviour.

Added MfaEnrollmentRouteNavigationTest, MfaEnrollmentFlowStateRestorationTest and MfaEnrollmentTotpRegenerationTest — data preservation across step switches and recreation, back-stack ordering, and TOTP regeneration.

Usage

val flowState = rememberMfaEnrollmentFlowState()
NavHost(...) {
    mfaEnrollmentDestinations(navController, configuration, /**/ flowState = flowState)
}

Maintainer note: Fixes internal CPRN-403

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request refactors the MFA enrollment flow to host steps as real navigation destinations, ensuring state survives step transitions and Activity recreation. This is achieved by introducing MfaEnrollmentFlowState and custom savers for CountryData and SmsEnrollmentSession. Feedback on the changes highlights a potential security risk of cross-user state leakage, suggesting that rememberMfaEnrollmentFlowState be keyed on the user's ID. Additionally, it is recommended to wrap a composition-time popBackStack() call in a LaunchedEffect to avoid side-effects during composition.

@demolaf
demolaf force-pushed the feat/mfa-enrollment-per-step-nav branch from 84abce8 to 4d4fe41 Compare September 2, 2026 01:10
@demolaf
demolaf force-pushed the feat/mfa-enrollment-per-step-nav branch from 4d4fe41 to 548c396 Compare September 2, 2026 13:17
@demolaf
demolaf force-pushed the feat/mfa-enrollment-per-step-nav branch from 548c396 to a38bb4f Compare September 2, 2026 13:30
Base automatically changed from feat/auth-per-step-nav-destinations to version-10.0.0-beta05 September 2, 2026 14:23
@russellwheatley
russellwheatley force-pushed the feat/mfa-enrollment-per-step-nav branch from a38bb4f to bfc6583 Compare September 2, 2026 14:23
@russellwheatley
russellwheatley merged commit bfc90ec into version-10.0.0-beta05 Sep 2, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in studio-2394994192-60a69 Sep 2, 2026
demolaf added a commit that referenced this pull request Sep 7, 2026
* fix(auth)!: remove non-functional MFA recovery codes (#2457)

* refactor(auth): scope phone verification loading state to the composition that owns it (#2454)

* refactor(auth): let the phone screen own its verification loading state

* fix(auth): read auth state per authUI instance when clearing loading on dispose

* fix(e2e): fix flaky Google credential-linking test (#2455)

* fix(auth): complete MFA challenge sign-in navigation and success callback (#2458)

* feat(auth): add stable resource ids for auth input fields (#2449)

* fix(auth): log diagnostic warning when Google sign-in NoCredentialException fallback exhausts

(cherry picked from commit 6fa4f00)
(cherry picked from commit aca99e7)
(cherry picked from commit 8784b13ce29739ed7785aab9ab6fe4faad2a2981)

* fix(e2e): retry and fail loudly when clearing Firebase Auth emulator data

(cherry picked from commit 8eca4fa)
(cherry picked from commit ac61312)
(cherry picked from commit 126ba985660ff272dbfda427b644ad4fb1ca6197)

* fix(e2e): don't swallow InterruptedException in emulator clear retry loop

(cherry picked from commit a87cfe3)
(cherry picked from commit 3f4ae70)
(cherry picked from commit 1f1ada380039ed5e7476dfc2e38a683e6edb4549)

* feat(auth): reshape reauthContent into a ReauthContentState content slot (#2452)

* feat(auth): reshape reauthContent into a ReauthContentState content slot

* fix(auth): address reauth review findings and retain state across recreation

* refactor(auth): make reauthentication a request-scoped state machine

* fix(auth): keep a proved reauthentication alive when its operation signs out

* fix(auth): tear down phone verification when a reauthentication attempt fails

* test(auth): cover sign-out-during-retry and phone reauth failure end to end

* test(auth): drop the flaky phone reauth e2e case

* test(auth): pin onComplete and factor refresh on successful MFA enrollment (#2462)

* test(auth): pin onComplete and factor refresh on successful MFA enrollment

* test(auth): pin the SMS MFA enrollment route through send, verify and resend

* test(auth): pin the missing TOTP secret guard and the resend's clean enroll

* feat(auth)!: make each email sign-in mode a real navigation destination (#2466)

* feat(auth): make each MFA enrollment step a real navigation destination (#2467)

* feat(auth)!: migrate auth navigation to Navigation 3 (#2469)

* feat(auth): make reauthentication a navigation destination (#2471)

* fix(auth): clear MFA enrollment flow state on every entry (#2473)

* feat(auth): make each phone auth step a real navigation destination (#2472)

* fix(auth): don't strand phone-only users on email verification after reload (#2474)

* test(auth): cover the write-through recoveries and the custom reauth slot's sheet chrome (#2476)

* test(auth): cover the three recoveries that write a value through to the step they move to

* test(auth): assert a custom reauth slot's email and phone steps stay inside the library sheet

---------

Co-authored-by: Ademola Fadumo <48495111+demolaf@users.noreply.github.com>
Co-authored-by: demolaf <demolafadumo@gmail.com>
@demolaf demolaf mentioned this pull request Sep 7, 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.

2 participants