passage_flex
Passkey Flex provides passkey support for existing authentication systems. It abstracts the complexities of native passkey APIs and provides a simple, clean solution to take your authentication to the next level.
The passage_flex Rust crate allows for verification of server-side authentication for applications using Passage Passkey Flex.
For full documentation, visit the Passkey Flex Docs and Docs.rs pages.
Installation
Install this crate using cargo:
cargo add passage_flex
Create a PassageFlex instance
A Passage AppID and API key are required. An App and AppID can be created in the Passage Console, and an API key can be created under your Application Settings. This API key grants access to the Passage management APIs to get and update information about users. This API key must be protected and stored in an appropriate secure storage location. It should never be hard-coded in the repository.
use PassageFlex;
let passage_flex = new;
Retrieve app info
To retrieve information about the app, use the get_app method.
use PassageFlex;
let passage_flex = new;
let app_info = passage_flex.get_app.await.unwrap;
println!;
Create a registration transaction
To create a transaction to start a user passkey registration, use the create_register_transaction method.
use PassageFlex;
let passage_flex = new;
let external_id = "a unique immutable string that represents your user".to_string;
let passkey_display_name =
"the label for the user's passkey that they will see when logging in".to_string;
let transaction = passage_flex
.create_register_transaction
.await
.unwrap;
Create an authentication transaction
To create a transaction to start a user passkey authentication, use the create_authenticate_transaction method.
use PassageFlex;
let passage_flex = new;
let external_id = "a unique immutable string that represents your user".to_string;
let transaction = passage_flex
.create_authenticate_transaction
.await
.unwrap;
Verify a nonce
To verify a nonce that you received from the end of of passkey registration or authentication ceremony, use the verify_nonce method.
use PassageFlex;
let passage_flex = new;
let nonce =
"a unique single-use value received from the client after a passkey ceremony".to_string;
match passage_flex.verify_nonce.await
Retrieve user info
To retrieve information about a user by their external ID -- which is the unique, immutable ID you supply to associate the Passage user with your user -- use the get_user method.
use PassageFlex;
let passage_flex = new;
// this is the same value used when creating a transaction
let external_id = your_user.id;
// get user info
let user_info = passage_flex.get_user.await.unwrap;
println!;
Retrieve a user's passkey devices
To retrieve information about a user's passkey devices, use the get_devices method.
use PassageFlex;
let passage_flex = new;
// this is the same value used when creating a transaction
let external_id = your_user.id;
// get devices
let passkey_devices = passage_flex.get_devices.await.unwrap;
for device in passkey_devices
Revoke a user's passkey device
To revoke a user's passkey device, use the revoke_device method.
use PassageFlex;
use ;
let passage_flex = new;
// this is the same value used when creating a transaction
let external_id = your_user.id;
let last_year = now.naive_utc.date - days;
// get devices
let passkey_devices = passage_flex.get_devices.await.unwrap;
for device in passkey_devices