Prompt
I'm building on AWS Cognito and want passkeys, how do I do it?
Latest observation
You can add passkeys to an AWS Cognito app, but the exact path depends on what you mean by “use Cognito”:
- Cognito User Pools don’t currently give you a simple “turn on passkeys” switch like they do for passwords/MFA.
- The usual approach is to implement passkeys in your app layer and then federate or map that sign-in into Cognito.
- If you want a fully native passwordless/passkey auth flow, you may need a custom auth flow or an external IdP that already supports passkeys.
The practical options
Option 1: Use passkeys in your app, then exchange for Cognito tokens
Best if you already use Cognito and want to keep it.
Flow:
- User signs in with a passkey using WebAuthn on your frontend.
- Your backend verifies the WebAuthn assertion.
- If valid, your backend issues a session/JWT or creates a Cognito-compatible login.
- Optionally, your backend can use Cognito custom auth to integrate that flow.
This is the most common “Cognito + passkeys” pattern.
Option 2: Use Cognito as the user directory, but delegate auth to an external IdP
If you use something like:
- Auth0
- Okta
- Azure AD B2C
- A passkey-capable custom IdP
Then Cognito can act as the broker/federation layer.
Option 3: Build a custom Cognito auth flow
Cognito supports custom authentication challenge flows with Lambda triggers:
DefineAuthChallengeCreateAuthChallengeVerifyAuthChallengeResponse
You can use these to implement a WebAuthn challenge/response flow.
This is the most “Cognito-native” way, but it’s also the most work.
Recommended architecture
If you want passkeys and Cognito together, I’d recommend:
Frontend
- Use WebAuthn / passkeys in browser or native app
- Libraries:
@simplewebauthn/browser@simplewebauthn/server
Backend
- Store passkey credentials:
credentialID- public key
- counter
- user ID
- transports / device metadata if needed
- Verify registration and authentication assertions server-side
- After success, mint a session or start a Cognito custom auth flow
Cognito
- Use a custom auth challenge or treat Cognito as the user directory after your app verifies identity
How to do it with Cognito custom auth
1. Enable custom authentication
In your Cognito User Pool client:
- Enable CUSTOM_AUTH flow
- Keep SRP/password disabled if you want passkey-only sign-in
2. Register passkey first
Typical registration flow:
- User enters email/username
- Backend checks whether the user exists in Cognito
- Backend creates a WebAuthn registration challenge
- Frontend calls
navigator.credentials.create() - Backend verifies attestation
- Backend stores the credential info linked to the Cognito user/sub
3. Authenticate with passkey
- User enters email/username
- Backend creates WebAuthn authentication challenge
- Frontend calls
navigator.credentials.get() - Backend verifies assertion
- If valid, Cognito custom auth Lambda returns success
Cognito Lambda triggers you’ll likely use
For custom auth:
- DefineAuthChallenge: decides if auth is complete
- CreateAuthChallenge: generates and sends/stores the challenge
- VerifyAuthChallengeResponse: checks the answer
Important note:
- Cognito doesn’t know WebAuthn natively
- Your Lambda/backend must store the challenge and verify the signed assertion
Example implementation pattern
Registration
Backend:
- Generate a WebAuthn registration options object
- Save
challengein your DB/cache - Return options to client
Client:
navigator.credentials.create({ publicKey: options })
Backend:
- Verify response
- Save credential public key + credential ID against user
Login
Backend:
- Generate WebAuthn login options for username
- Save challenge
- Return options
Client:
navigator.credentials.get({ publicKey: options })
Backend:
- Verify assertion using stored credential public key
- If valid, authenticate the user
Then either:
- create your own session/JWT, or
- call Cognito custom auth / token issuance flow
Important Cognito limitations to know
- Cognito User Pools do not provide first-class passkey support comparable to a dedicated passkey IdP.
- You cannot simply “enable passkeys” and be done.
- If you need:
- native passkey UX
- device-bound login
- synced passkeys
- account recovery
- step-up auth you’ll need to design these yourself.
If you want the simplest production approach
Best overall
- Use WebAuthn passkeys in your app
- Verify on your backend
- Use Cognito only if you need it for:
- user profile management
- group/claim mapping
- existing AWS integration
If you’re starting fresh and passkeys are the main auth method, consider whether Cognito is still the best primary auth system for your use case.
What I can give you next
I can help you with any of these:
- A working architecture diagram
- A step-by-step AWS Cognito custom auth setup
- Node.js backend code using SimpleWebAuthn
- React frontend passkey registration/login code
- Lambda trigger examples for Cognito custom auth
If you want, I can give you a complete end-to-end sample for:
- Cognito + passkeys + Node.js + React