Skip to content

FRD: Auth Platform Flows Recipe

Document Summary

FieldDetails
Feature NameAuth Platform Flows Recipe
StatusDraft
OwnerDavid Holmes
ContributorsEngineering, Security
Target Releasev2.0.0 (P2)
Related LinksRoadmap item #80, ADR-027 (Default Tech Stack)
Last Updated2026-05-26

Introduction

Overview

The Auth Platform Flows recipe provides copy-pasteable implementations for the authentication flows that sit beyond the existing login, signup, and MFA-verify widgets. It covers password reset, email verification, invitation acceptance, MFA setup (TOTP and recovery codes), recovery-code regeneration, and SSO handoff. Each flow is a self-contained page component with stories, tests, and documentation showing how to wire it to a backend auth service.

Goals

  • Provide complete, copy-pasteable page components for each auth flow.
  • Demonstrate proper state management for multi-step auth flows (using wizard pattern where applicable).
  • Show secure handling of tokens, codes, and sensitive form data.
  • Document the expected backend API contract for each flow.
  • Include accessible, mobile-responsive implementations.
  • Ship with stories covering every flow state and tests covering logic.

Non-Goals

  • Rebuilding the existing login, signup, or verify-MFA widgets.
  • Implementing a real auth backend or identity provider.
  • Providing session management or token refresh logic.
  • Building a user management admin panel.
  • Implementing biometric authentication.

Scope

In Scope

AreaDescription
Password reset flowRequest reset (email input) -> check email prompt -> reset password (new password input with token) -> success confirmation
Email verification flowVerify email with token from URL -> success or expired/invalid states
Invitation acceptance flowAccept invite with token -> set password -> success
MFA setup flow (TOTP)Show QR code -> verify with authenticator code -> display recovery codes -> confirm save
Recovery code managementRegenerate recovery codes -> confirm action -> display new codes -> confirm save
SSO handoff flowSSO provider selection -> redirect to IdP -> callback handling states (loading, error)
Shared auth layoutCentered card layout for auth pages with logo and footer
Mock auth serviceMock API layer for testing and stories
StoriesAll flow states demonstrated
TestsLogic and state management coverage
Recipe MDXDocumentation with API contracts and integration guide

Out of Scope

AreaReason
Login / signup / MFA verify widgetsAlready exist as login-form.tsx, signup-form.tsx, verify-mfa-form.tsx
Real auth backendConsumer responsibility
Session management / token refreshSeparate concern; covered by the consumer’s auth infrastructure
User profile managementDifferent feature
Biometric authenticationSpecialized; not standard flow
OAuth provider implementationConsumer responsibility; recipe shows the redirect pattern

Users and Pain Points

User Groups

UserDescriptionNeeds
Application developersEngineers implementing auth flows beyond login/signupComplete, secure reference implementations for each flow
Security engineersTeam members reviewing auth implementationDocumented security considerations for each flow
QA engineersTesters verifying auth flowsStories showing every state including error cases
New team membersEngineers onboarding to auth implementationWorking examples showing how to handle tokens, multi-step flows, and error states

Pain Points

UserPain PointImpact
Application developersAuth widgets exist for login/signup/MFA-verify, but no reference for the surrounding flowsPassword reset, email verification, and MFA setup are built from scratch each time
Application developersMulti-step auth flows (MFA setup) are complex to implement correctlyDevelopers skip steps (e.g., not showing recovery codes) or implement them insecurely
Application developersNo documented backend API contract for auth flowsEach app defines its own API shape; hard to share auth infrastructure
Security engineersRecovery codes are often displayed insecurely (no copy button, no download, no confirmation)Users lose access to their accounts when they cannot recover codes

Definitions

TermDefinition
Password reset flowThe complete flow from requesting a reset email to setting a new password via a tokenized link
Email verificationConfirming a user’s email address via a tokenized link sent to that address
Invitation acceptanceA flow where a new user accepts an invite, sets their password, and joins an organization
TOTPTime-based One-Time Password; a standard MFA method using authenticator apps
Recovery codesOne-time-use backup codes that allow login when the primary MFA method is unavailable
SSO handoffRedirecting a user to an external identity provider (SAML, OIDC) and handling the return callback
Auth tokenA short-lived, single-use token embedded in a URL for email verification, password reset, or invitation acceptance

Current State

Existing Behavior

The design system ships three auth widgets: login-form.tsx (email/password login), signup-form.tsx (registration), and verify-mfa-form.tsx (MFA code entry). These handle the core authentication interaction but not the supporting flows.

Current Limitations

  • No password reset flow (request, check email, set new password).
  • No email verification flow.
  • No invitation acceptance flow.
  • No MFA setup flow (QR code display, code verification, recovery codes).
  • No recovery code regeneration flow.
  • No SSO handoff pattern.
  • No shared auth page layout.

Existing Workarounds

  • Developers implement each flow from scratch, often with inconsistent UX and missing states.
  • Recovery codes are sometimes shown in a plain alert dialog without copy/download.
  • SSO handoff is implemented with raw redirects without loading or error states.

Proposed Solution

Summary

Create a recipe folder (src/recipes/auth-flows/) containing page components for each auth flow, a shared auth layout, a mock auth service, and documentation. Each flow is a self-contained component that can be copied independently.

Key Capabilities

  • PasswordResetRequest page: email input, submit, check-email prompt.
  • PasswordResetConfirm page: token validation, new password input with strength indicator, success state.
  • EmailVerification page: token extraction from URL, verification call, success/expired/invalid states.
  • InvitationAcceptance page: token validation, set password, accept invite, success.
  • MfaSetup wizard: display TOTP secret and QR code -> verify code -> display recovery codes -> confirm saved.
  • RecoveryCodeRegeneration page: confirm action -> display new codes -> confirm saved.
  • SsoHandoff page: provider selection -> redirect initiation -> callback loading/error states.
  • AuthLayout shared layout: centered card with logo, heading, and footer.
  • RecoveryCodeDisplay component: code grid with copy-all, download-as-text, and print actions.

User Experience

Each flow follows a clear progression with appropriate states. Users see loading indicators during API calls, clear error messages on failure, and success confirmations on completion. Recovery codes are displayed in a secure, actionable format with multiple save options.

Developer Experience

Developers copy individual flow components or the entire recipe. Each flow accepts an authService prop (or uses context) for backend integration. The mock auth service makes all flows testable and previewable in Storybook. The recipe MDX documents the expected API contract for each flow.


Requirements

IDRequirementPriorityNotes
FR-001The recipe must include a password reset flow (request + confirm)MustCore auth flow
FR-002The recipe must include an email verification flowMustCore auth flow
FR-003The recipe must include an invitation acceptance flowMustCommon enterprise flow
FR-004The recipe must include an MFA setup flow (TOTP)MustSecurity requirement
FR-005The recipe must include a recovery code display and regeneration flowMustMFA recovery
FR-006The recipe must include an SSO handoff flowMustEnterprise auth
FR-007The recipe must include a shared auth layoutMustConsistent auth UX
FR-008The recipe must ship with stories for every flow stateMustVisual reference
FR-009The recipe must ship with testsMustQuality gate
FR-010The recipe must document the expected backend API contract per flowMustIntegration guide

Priority Definitions

PriorityMeaning
MustRequired for this feature to ship.
ShouldImportant, but can be deferred if needed.
CouldNice to have. Not required for initial release.

Functional Requirements

IDRequirementUser BenefitPriority
FUNC-001PasswordResetRequest: email input, submit, show “check your email” on successInitiates reset flowMust
FUNC-002PasswordResetConfirm: extract token from URL, validate token, show new-password form with strength indicator, submit, show successCompletes password resetMust
FUNC-003PasswordResetConfirm: show expired/invalid token state with “request new link” actionError recoveryMust
FUNC-004EmailVerification: extract token from URL, call verify, show success or expired/invalid stateEmail confirmationMust
FUNC-005InvitationAcceptance: extract token, validate invite, show set-password form, submit, show successNew user onboardingMust
FUNC-006MfaSetup wizard: step 1 (show QR code + TOTP secret), step 2 (verify 6-digit code), step 3 (display recovery codes), step 4 (confirm saved)Complete MFA enrollmentMust
FUNC-007MfaSetup uses PanelWizard pattern for step managementPer P3 design principlesMust
FUNC-008RecoveryCodeDisplay: shows codes in a grid with copy-all, download-as-text, and print buttonsUsers can securely save recovery codesMust
FUNC-009RecoveryCodeRegeneration: confirmation prompt, regenerate, display new codes, confirm savedRecovery code managementMust
FUNC-010SsoHandoff: provider list, initiate redirect, callback loading state, callback error state with retryEnterprise SSOMust
FUNC-011All forms show inline validation errors (not just toasts)Field-level error feedback per P3 principlesMust
FUNC-012All flows show loading states during API callsNo dead UI during network requestsMust
FUNC-013Password inputs include a show/hide toggleUsabilityShould
FUNC-014Password strength indicator shows requirements and visual feedbackUsers create strong passwordsShould

Non-Functional Requirements

IDRequirementCategoryPriority
NFR-001Recipe code must be copy-pasteable and self-containedMaintainabilityMust
NFR-002All recipe code must pass TypeScript strict modeCorrectnessMust
NFR-003Stories must render in light and dark themesCompatibilityMust
NFR-004Recovery codes must never be logged to the consoleSecurityMust
NFR-005Token extraction from URL must sanitize inputSecurityMust
NFR-006Password inputs must use type="password" (togglable) and autocomplete="new-password" or autocomplete="current-password"SecurityMust
NFR-007All forms must prevent double-submission during loadingCorrectnessMust
NFR-008Auth layout must be responsive and centered on all screen sizesCompatibilityMust

API / Interface Requirements

Public API

This is a recipe, not a published package. No new public API is exported from the design system.

NameTypeDescriptionRequired
Recipe foldersourcesrc/recipes/auth-flows/ with flow components, layout, and mock serviceYes
Recipe MDXdocumentationStorybook MDX page with integration guide and API contractsYes
Recipe storiesstoriesStorybook stories covering every flow stateYes
Recipe teststestsVitest tests for flow logic and state managementYes

Example Usage

// Password reset request page
import { PasswordResetRequest } from "./auth-flows";
function ResetPage() {
return (
<AuthLayout logo="/logo.svg" heading="Reset your password">
<PasswordResetRequest
onSubmit={async (email) => {
await authApi.requestPasswordReset(email);
}}
/>
</AuthLayout>
);
}
// MFA setup wizard
import { MfaSetup } from "./auth-flows";
function SetupMfaPage() {
return (
<AuthLayout logo="/logo.svg" heading="Set up two-factor authentication">
<MfaSetup
onGenerateSecret={async () => authApi.generateTotpSecret()}
onVerifyCode={async (code) => authApi.verifyTotpCode(code)}
onComplete={() => router.navigate("/settings")}
/>
</AuthLayout>
);
}

API Notes

  • Each flow component accepts callback props for backend integration (onSubmit, onVerify, etc.).
  • The mock auth service simulates realistic delays and configurable failure modes.
  • Token extraction from URL uses URLSearchParams; the recipe documents the expected parameter names.
  • MfaSetup returns recovery codes from the onVerifyCode callback response.
  • The recipe documents the expected API contract for each flow:
    • POST /auth/reset-password/request - { email }
    • POST /auth/reset-password/confirm - { token, password }
    • POST /auth/verify-email - { token }
    • POST /auth/invitations/accept - { token, password }
    • POST /auth/mfa/totp/setup - returns { secret, qrCodeUrl }
    • POST /auth/mfa/totp/verify - { code } - returns { recoveryCodes }
    • POST /auth/mfa/recovery-codes/regenerate - returns { recoveryCodes }

Accessibility Requirements

IDRequirementNotes
A11Y-001All forms must have accessible labels for every input&lt;label&gt; elements or aria-label
A11Y-002Error messages must be associated with their inputs via aria-describedbyScreen readers announce errors in context
A11Y-003Success and error states must be announced to screen readersrole="alert" for errors, role="status" for success
A11Y-004Password visibility toggle must have an accessible label”Show password” / “Hide password”
A11Y-005MFA setup wizard must announce step changesaria-live on step indicator or step heading
A11Y-006Recovery code copy button must announce “Copied” to screen readersaria-live="assertive" confirmation
A11Y-007QR code must have a text alternative (the TOTP secret as selectable text)Users who cannot scan QR codes can enter the secret manually
A11Y-008All interactive elements must be keyboard accessibleTab, Enter, Space, Escape where applicable
A11Y-009Auth layout must have a skip-to-content linkStandard a11y pattern

Checklist

  • Keyboard support is defined.
  • Focus behavior is defined.
  • Screen reader behavior is defined.
  • Color contrast requirements are met.
  • Reduced motion behavior is considered.
  • Semantic HTML expectations are documented.
  • ARIA usage is defined only where needed.

Content and Documentation Requirements

IDRequirementLocationPriority
DOC-001Recipe MDX page with overview and flow diagramsStorybook MDXMust
DOC-002Per-flow integration guide with API contractStorybook MDXMust
DOC-003Security considerations sectionStorybook MDXMust
DOC-004”How to customize” section for each flowStorybook MDXMust
DOC-005Testing guideStorybook MDXMust
DOC-006Accessibility notes per flowStorybook MDXMust

Documentation Should Include

  • Overview of all auth flows
  • When to use each flow
  • Prerequisites (existing auth widgets, backend API)
  • Per-flow integration guide with expected API contract
  • Security considerations (token handling, password rules, recovery code safety)
  • Customization guide (branding, copy, validation rules)
  • Testing with mock auth service
  • Accessibility notes
  • Common mistakes (e.g., not validating tokens on load, logging recovery codes)

Dependencies

DependencyTypeOwnerStatusNotes
login-form.tsxDesign SystemDavid HolmesReadyExisting auth widget (reference, not directly imported)
signup-form.tsxDesign SystemDavid HolmesReadyExisting auth widget (reference)
verify-mfa-form.tsxDesign SystemDavid HolmesReadyExisting auth widget (reference)
React 18+EngineeringDavid HolmesReadyPeer dependency
VitestEngineeringDavid HolmesReadyTest runner
Design system form componentsDesign SystemDavid HolmesReadyInput, button, etc.
QR code generation libraryEngineeringDavid HolmesUnknownNeeded for TOTP setup; evaluate qrcode or similar

Risks and Tradeoffs

Risk / TradeoffImpactMitigation
Recipe defines an API contract that may not match consumer backendsDevelopers must adapt the contractDocument the contract as a recommendation; keep callback props generic
QR code generation adds a dependencyBundle size increaseEvaluate lightweight options; document as a peer dependency of the recipe
MFA setup wizard complexityMulti-step flows are harder to implement and testUse PanelWizard pattern per P3 principles; thorough testing and stories
Recovery code display may be screenshotted or photographedSecurity riskDocument user guidance about secure storage; provide download-as-file option
SSO handoff requires redirect, which stories cannot fully demonstrateLimited story coverage for redirect behaviorShow the pre-redirect and callback states; document the redirect in the MDX
Token validation patterns differ across providersRecipe pattern may not fit all providersKeep token handling generic; document the pattern, not a specific provider

Open Questions

IDQuestionOwnerStatusResolution
Q-001Should the recipe include a “remember this device” checkbox for MFA?David HolmesOpen
Q-002Should recovery codes be displayed as a downloadable text file, a printable page, or both?David HolmesOpen
Q-003Should the SSO flow support a configurable list of providers or is that the consumer’s responsibility?David HolmesOpen
Q-004Should the password strength indicator use zxcvbn or a simpler rule-based checker?David HolmesOpen
Q-005Should the invitation acceptance flow include an organization name and inviter display?David HolmesOpen

Acceptance Criteria

IDCriteriaRelated Requirement
AC-001Password reset request flow: email submission shows “check your email” stateFUNC-001
AC-002Password reset confirm flow: expired token shows error with “request new link”FUNC-003
AC-003Email verification: valid token shows success; expired token shows errorFUNC-004
AC-004Invitation acceptance: valid invite shows set-password form; submission shows successFUNC-005
AC-005MFA setup wizard progresses through QR code, verification, recovery codes, and confirmation stepsFUNC-006
AC-006MFA setup uses PanelWizard patternFUNC-007
AC-007Recovery codes display with copy-all and download actionsFUNC-008
AC-008Recovery code regeneration: confirm, display new codes, confirm savedFUNC-009
AC-009SSO handoff: shows provider list and handles callback loading/error statesFUNC-010
AC-010All forms show inline validation errors, not just toastsFUNC-011
AC-011Stories cover every flow state (loading, success, error, expired)FR-008
AC-012Unit tests pass covering flow logic and state transitionsFR-009
AC-013All recipe code passes TypeScript strict modeNFR-002
AC-014Recipe MDX renders in Storybook without errorsDOC-001
AC-015Recovery codes are never logged to the console in any code pathNFR-004

LLM Handoff Instructions

Expected LLM Behavior

  • Follow the requirements and acceptance criteria in this document.
  • Do not expand scope beyond the In Scope section.
  • Respect the Out of Scope section.
  • Use existing design system form components (inputs, buttons, etc.); do not rebuild them.
  • Use PanelWizard pattern for the MFA setup flow per P3 design principles.
  • Keep inline validation errors on fields, not toasts, per P3 design principles.
  • Use semantic toasts only for success confirmations, not field errors, per P3 design principles.
  • Token extraction from URL must sanitize and validate input.
  • Never log recovery codes, tokens, or passwords.
  • Each flow component should accept callback props for backend integration.
  • Place the recipe in src/recipes/auth-flows/.

LLM Should Not

  • Invent undocumented product behavior.
  • Implement real authentication backends or identity providers.
  • Modify existing auth widgets (login-form.tsx, signup-form.tsx, verify-mfa-form.tsx).
  • Add heavy dependencies without justification (evaluate lightweight QR code options).
  • Store tokens or passwords in localStorage.
  • Log sensitive data (tokens, passwords, recovery codes).
  • Use alert() or confirm() for security-sensitive prompts.
  • Skip the recovery code display step in MFA setup.

Decision Log

DateDecisionReasonOwner
2026-05-26Recipe, not published componentsAuth flows are heavily customized per application; recipes give developers full controlDavid Holmes
2026-05-26Each flow is an independent componentConsumers may only need some flows; independence simplifies adoptionDavid Holmes
2026-05-26Use PanelWizard for MFA setupPer P3 design principles: multi-step flows with dependent choices use PanelWizardDavid Holmes
2026-05-26Document API contracts as recommendations, not requirementsDifferent backends have different APIs; the contract is guidanceDavid Holmes
2026-05-26Recovery codes with copy-all and downloadUsers need multiple options to securely save codes; copy and download cover most use casesDavid Holmes

Document History

DateAuthorChange
2026-05-26David HolmesInitial draft