Skip to content

feat(auth): require MFA JWT for TOTP enrolment - #21037

Draft
StaberindeZA wants to merge 1 commit into
mainfrom
fxa-14311-backend
Draft

feat(auth): require MFA JWT for TOTP enrolment#21037
StaberindeZA wants to merge 1 commit into
mainfrom
fxa-14311-backend

Conversation

@StaberindeZA

@StaberindeZA StaberindeZA commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Because

  • Step-up auth re-enters no password, so a hijacked session could enrol an AAL2 factor — and trigger the destructive recovery-method clear in /totp/create — with only a session token, no proof of email possession. This requires an email-OTP-derived mfa:2fa JWT for all TOTP enrolment, closing that hole.

This pull request

  • Consolidates TOTP enrolment onto /mfa/totp/{create,setup/verify,setup/complete}, guarded by the mfa strategy + mfa:2fa scope, and removes the ungated session-token routes so enrolment always requires the JWT.
  • Removes the now-dead session-token TOTP methods (create/verify/complete + the replace pair) from fxa-auth-client; only the *WithJwt variants remain.
  • Migrates the auth-server test client to mint an mfa:2fa JWT for setup, and the functional enableTotpOnAccount helper + call sites to the email-OTP/JWT flow.
  • Adds route-guard unit assertions and an integration test proving a bare session token is rejected (401 / errno 223) before reaching the enrolment handlers.

Issue that this pull request solves

Closes: FXA-14390

Checklist

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate). — n/a (no UI)
  • I have manually reviewed all AI generated code.

How to review

Other information

  • Verified locally: nx lint (auth-server, auth-client, functional-tests) ✅; totp.spec.ts unit 24/24 ✅; the 5 affected integration specs 84/84 ✅.

@StaberindeZA
StaberindeZA force-pushed the fxa-14311 branch 6 times, most recently from 8bf3c4b to 9170fad Compare August 20, 2026 12:10
Because:
 - Step-up auth re-enters no password, so a hijacked session could enrol
   an AAL2 factor and trigger the destructive recovery-method clear with
   only a session token — no proof of email possession.

This commit:
 - Consolidates the TOTP enrolment routes onto /mfa/totp/{create,setup/verify,
   setup/complete}, guarded by the `mfa` strategy + `mfa:2fa` scope, and removes
   the ungated session-token routes so enrolment always requires an email-OTP JWT.
 - Removes the now-dead session-token TOTP methods (create/verify/complete and
   the replace pair) from fxa-auth-client; only the *WithJwt variants remain.
 - Migrates the auth-server test client to mint an mfa:2fa JWT for TOTP setup,
   and updates the functional-test enableTotpOnAccount helper and its call sites
   to the email-OTP/JWT flow.
 - Adds route-guard unit assertions and an integration test proving a bare
   session token is rejected (401/223) before reaching the enrolment handlers.

Closes FXA-14390
Base automatically changed from fxa-14311 to main August 24, 2026 18:11
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.

1 participant