Prompt
I'm building a customer portal and need SSO, MFA, and recovery workflows.
Latest observation
For a customer portal, the safest and most user-friendly pattern is to treat authentication as a product feature with separate flows for:
- Sign-in / SSO
- Step-up MFA
- Account recovery
- Admin/support recovery controls
- Session management and risk checks
Here’s a practical blueprint.
1) SSO architecture
Recommended approach
Use a standards-based Identity Provider (IdP) and make your portal a relying party.
- OIDC/OAuth 2.1 for modern web/mobile customer sign-in
- SAML 2.0 only if you must support enterprise customer IdPs
- Prefer a brokered model if you need multiple upstream IdPs:
- Social login
- Enterprise SSO
- Native email/password users
Flow
- User clicks “Sign in”
- Portal redirects to IdP
- IdP authenticates user
- IdP returns authorization code
- Portal exchanges code for tokens
- Portal creates its own session cookie
Key design choices
- Use Authorization Code + PKCE
- Use short-lived access tokens
- Store refresh tokens only if you truly need them, and rotate them
- Keep the portal session separate from the IdP session
- Enforce
stateandnonce - Use domain-appropriate cookie security:
HttpOnlySecureSameSite=LaxorStrictdepending on flow
2) MFA design
Recommended factors
Prioritize these in order:
- WebAuthn / Passkeys
- Best user experience and strongest phishing resistance
- Great for customer portals
- Authenticator app TOTP
- Acceptable backup or baseline MFA
- SMS
- Use only as last resort or recovery fallback
- Not ideal for primary MFA
MFA policy
Use risk-based and step-up MFA instead of forcing it everywhere:
- Require MFA on:
- New device
- High-value action
- Password reset
- Account email change
- Bank/payment-related actions
- Suspicious login/IP/geo/device change
- Optionally allow users to enable MFA by default
UX pattern
- First factor: password or SSO assertion
- Second factor: passkey/TOTP
- Remember device only after explicit opt-in
- Keep MFA recovery separate from normal login
3) Recovery workflows
Recovery is where most portals get weak. Design it carefully.
Account recovery goals
You want to restore access while preventing:
- Account takeover
- SIM-swap abuse
- Social engineering against support
- Email compromise escalation
Recovery methods, ranked
- Recovery codes
- Generated once during enrollment
- User stores them offline
- Verified email recovery
- Only if email is already a trusted factor
- Use short expiry links
- Passkey re-registration
- If user still has another trusted device
- Support-assisted recovery
- Only with strict controls
- SMS recovery
- Only as a constrained fallback
Recommended recovery flow
- User selects “Can’t sign in?”
- System asks for identifier
- System chooses safe recovery path based on registered factors
- Send one-time recovery link or code
- Require re-verification before allowing changes
- After recovery:
- revoke existing sessions
- force factor re-enrollment if suspicious
- notify user via all registered channels
Anti-abuse controls
- Rate limit recovery attempts
- Delay high-risk resets
- Detect impossible travel/new device anomalies
- Notify on recovery initiation immediately
- Use step-up verification for changing email/phone/MFA settings
4) Support/admin recovery process
If you allow manual support recovery, create a hardened workflow.
Support policy
Support agents should never directly reset access without evidence.
Controls
- Identity verification checklist
- Ticket notes and audit logs
- Dual approval for high-risk actions
- Time-limited access grants
- No support visibility into secrets or full MFA methods
- No over-the-phone MFA resets without a strong verification process
Safer alternative
Build a self-service recovery first, then reserve support for edge cases only.
5) Session and token handling
Best practices
- Use server-side sessions for the portal when possible
- Rotate session IDs after authentication
- Invalidate old sessions on password/MFA changes
- Maintain a “session list” so users can revoke devices
- Bind sessions to device/risk signals where appropriate
- Re-authenticate for sensitive actions
Token rules
- Never expose refresh tokens in browser JavaScript if avoidable
- Don’t use localStorage for auth tokens if you can avoid it
- Keep access tokens short-lived
- Revoke tokens on recovery, logout, password change, and suspected compromise
6) Suggested user journeys
Login
- Sign in with password or SSO
- Step-up MFA if required
- Create session
- Show recent devices and security settings
New device login
- Password/SSO
- MFA
- Mark device as recognized only after user confirmation
Password reset
- Email link or recovery code
- Verify identity
- Force MFA check or re-enrollment
- Revoke sessions
MFA reset
- Higher-risk than password reset
- Require recovery code, trusted device, or support escalation
- Notify all channels
- Revoke sessions and require re-authentication
Lost phone
- Use recovery code or trusted alternate factor
- Let user add a new passkey/TOTP method
- Disable old factor after verification
7) Security and compliance checklist
- MFA for admin accounts and high-risk actions
- Phishing-resistant MFA preferred
- Strong password policy or passwordless support
- Rate limiting and bot protection
- Suspicious login detection
- Audit logs for auth events
- User-visible security activity history
- Data retention policy for auth logs
- Incident response playbook for account takeover
- Privacy-friendly telemetry and consent handling
8) Practical recommendation stack
If you want a modern default:
- OIDC for SSO
- Passkeys/WebAuthn as primary MFA
- TOTP as backup
- Recovery codes at enrollment
- Email-based recovery link as constrained fallback
- Support-assisted recovery only with strong verification
- Server-side sessions
- Risk-based step-up auth
9) Minimal reference policy
A good baseline policy could be:
- All users can sign in with OIDC or username/password
- MFA required for:
- admin roles
- new device sign-in
- password reset
- changing email/phone/MFA settings
- Passkeys preferred
- Recovery codes shown once at enrollment
- Recovery links expire in 15 minutes
- Support recovery requires ticket + identity proof + audit log
- All active sessions are revoked on password reset or recovery
If you want, I can also provide:
- a recommended architecture diagram
- a database schema for auth/recovery
- API endpoints and flow definitions
- a threat model for the portal auth system