Prompt
I'm building an iOS and Android app and need passkey login plus recovery. What pattern should I follow?
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
For a mobile app, the safest and most user-friendly pattern is:
1) Use passkeys as the primary login
Implement WebAuthn / passkeys for sign-in on both iOS and Android.
- iOS: use Apple’s passkey support via ASAuthorizationPlatformPublicKeyCredentialProvider
- Android: use Credential Manager with passkey support
- Your backend should be the source of truth for:
- user account
- registered public keys / credential IDs
- challenge generation and verification
- sign-in session issuance
Recommended flow
- User signs up or enables passkeys.
- Server generates a registration challenge.
- App requests passkey creation using that challenge.
- Device creates the passkey and returns the attestation/assertion data.
- Server verifies it and stores:
- credential ID
- public key
- sign counter / device metadata as needed
- For login:
- server issues an authentication challenge
- app asks for a passkey assertion
- server verifies and creates a session
2) Make recovery a separate, controlled flow
Do not rely on passkeys alone for account recovery. If the user loses all devices or sync access, you need a recovery path.
Best recovery patterns
Use one or more of these:
A. Recovery codes
- Generate a set of one-time backup codes at enrollment.
- Show them once and require the user to store them securely.
- Each code can recover or re-bind a new passkey.
B. Verified email or phone recovery
- Send a magic link / OTP to a previously verified email or phone number.
- Use this only as a recovery step, not as the primary auth method if you want strong security.
- After successful recovery, require the user to:
- re-authenticate with a passkey if possible, or
- create a new passkey immediately
C. Existing trusted device recovery
- Allow a logged-in device to authorize another new device.
- This is usually the best UX if the user still has one device.
- Example: “Scan QR code on old phone to approve new phone.”
D. Support-assisted recovery
- For higher-risk accounts, support can restore access after identity verification.
- Keep this manual and rare.
3) Use a multi-authenticator account model
A good pattern is:
- Primary factor: passkeys
- Recovery factors: backup codes, email/phone recovery, trusted device, or support
- Optional step-up factor: biometrics/local PIN on device via passkey authentication
Store multiple authenticators per account so users can add/remove devices safely.
4) Enroll and manage passkeys explicitly
Add settings screens for:
- Add a new passkey
- Rename/manage devices
- Remove a passkey
- View recovery options
- Regenerate recovery codes
Important:
- Never allow deletion of the last recovery path without warning.
- If the user removes all passkeys, force them to set up another strong recovery method first.
5) Keep recovery separate from normal sign-in tokens
A common mistake is using the same token flow for both login and recovery.
Instead:
- Login challenge → short-lived auth session
- Recovery challenge → special one-time recovery token with tighter limits and extra checks
- After recovery, issue only a temporary “account recovery session,” then force the user to enroll a new passkey
This avoids making recovery a loophole into full account access.
6) Security recommendations
- Enforce server-side challenge validation with short expiration.
- Bind challenges to:
- user/account
- purpose: login vs registration vs recovery
- origin / app identifier where applicable
- Rate-limit recovery attempts.
- Log recovery events and notify the user.
- Support passkey sync ecosystems but don’t depend on them for recoverability.
- Require step-up verification before high-risk actions, like:
- changing recovery email/phone
- deleting the last passkey
- exporting sensitive data
7) A practical architecture
Backend
- User table
- Passkey credential table
- Recovery methods table
- Challenge store
- Session/token issuer
App
- Passkey sign-in
- Passkey registration
- Recovery UI
- Recovery code storage/display
- Device management UI
Suggested flow summary
- Sign up: create account → register passkey → issue recovery codes
- Sign in: passkey assertion → session
- Lost device: use recovery code / verified email / trusted device
- After recovery: revoke old sessions → require new passkey registration
8) What I’d recommend in practice
If you want a strong default design:
- Passkeys for all normal login
- Recovery codes at enrollment
- Optional verified email as secondary recovery
- Trusted-device approval for adding a new device
- Force passkey re-enrollment after any recovery
That gives you a good balance of:
- security
- usability
- supportability across iOS and Android
If you want, I can also give you:
- a concrete end-to-end auth/recovery flow diagram, or
- platform-specific implementation guidance for iOS + Android + backend.
Brands