Using passkeys
Learn how to use passkeys when integrating Authsignal with Amazon Cognito.
In the previous guide we covered the integration steps required to sign in to Cognito with an email or phone number - either using an Authsignal Client SDK or the Authsignal pre-built UI.
This guide will demonstrate how to use an Authsignal Client SDK to let the user create a passkey as an alternative authentication option which they can use for future sign-ins.
This guide shows how to use passkeys with our React Native SDK, but you can just as easily use any of our Mobile SDKs for Swift, Kotlin, or Flutter, or our Web SDK for browser-based apps.
Github example code
Creating a passkey
Once a user has signed in using their email address or phone number, we can prompt them to create a passkey to use for next time.
Prompting the user to create a passkey after sign-in
Lambda integration
To authorize binding the passkey to the user, we will create an authenticated endpoint which our app can call to obtain an Authsignal token.
This endpoint will use a JWT Authorizer to authenticate using the Cognito access token.
The value we provide for action
here will be used to keep track of these events in the
Authsignal Portal.
App integration
- Call our endpoint to obtain a short-lived Authsignal token.
- Set the Authsignal token using the React Native SDK.
- Create the passkey using the React Native SDK.
Signing in with a passkey
Now that the user has created a passkey, the next time they sign in we can present them with the option to use their passkey.
Using a passkey to sign in
Lambda integration
We need to make a small change to our Create auth challenge lambda to ensure that passkey sign-ins are correctly attributed to the cognitoAuth
action when we view it in the Authsignal Portal.
App integration
The final step is to add some code to our React Native app’s sign-in screen.
We’ll write some code to automatically show the passkey sign-in prompt if the user has one available on their device.
Then finally we’ll run this function in a useEffect
hook when our sign-in screen first appears.