Rust

passkeys

Module

WebAuthn passkeys for one relying party: registration and sign-in ceremonies with discoverable credentials, required user verification and no attestation.

Contents

5 submodules, and what the module defines itself.

use utopia_auth::passkeys::RelyingParty;
Rust
pub struct RelyingParty

The relying party passkeys are bound to: its ID (a domain), display name and the exact origins allowed to run ceremonies.

Rust
use utopia_auth::passkeys::RelyingParty;

let a = RelyingParty::new("example.com", "Example", vec!["https://b.example.com".into(), "https://a.example.com".into()]);
let b = RelyingParty::new("example.com", "Example", vec!["https://a.example.com".into(), "https://b.example.com".into()]);
// The fingerprint ignores the order of the origins.
assert_eq!(a.fingerprint(), b.fingerprint());
assert_eq!(a.fingerprint().len(), 64);

passkeys::cbor

Own page

The CBOR decoder for passkey data: attestation objects, authenticator data and public keys, decoded into Values.

Integers become decimal strings and map keys become array keys. Errors are bytes: they quote map keys, which need not be UTF-8.

passkeys::ceremony

Own page

Passkey registration and sign-in ceremonies: the options sent to the browser, the state kept in between, and the verification of what comes back.

use utopia_auth::passkeys::ceremony::Ceremony;
Rust
pub struct Ceremony

WebAuthn registration and sign-in for one relying party: discoverable credentials, required user verification, no attestation.

use utopia_auth::passkeys::ceremony::Challenge;
Rust
pub struct Challenge

A started ceremony: options for the browser and the opaque state to keep until the credential comes back.

use utopia_auth::passkeys::ceremony::Counter;
Rust
pub struct Counter

The signature counter policy: the counter must increase, except for synced (backup-eligible) passkeys and authenticators without a counter (always 0).

use utopia_auth::passkeys::ceremony::Credential;
Rust
pub struct Credential

A verified passkey: the record to store and the identifier to find it by.

use utopia_auth::passkeys::ceremony::StrictCounter;
Rust
pub struct StrictCounter

The strict signature counter policy: the counter must always increase.

Rust
pub const TIMEOUT: i64 = 300

Seconds a ceremony stays valid.

passkeys::cose

Own page

Passkey public keys in COSE form (RFC 9052/9053), and the signature algorithms ceremonies accept: ES256 and RS256.

use utopia_auth::passkeys::cose::PublicKey;
Rust
pub struct PublicKey

A passkey's public key: its normalized COSE_Key map.

use utopia_auth::passkeys::cose::Algorithm;
Rust
pub enum Algorithm

A signature algorithm passkeys may use, offered to the browser in pubKeyCredParams.

passkeys::origin

Own page

The web origins allowed to run passkey ceremonies for a relying party.

use utopia_auth::passkeys::origin::Origin;
Rust
pub struct Origin

The web origins allowed to run ceremonies for a relying party: HTTPS on the RP ID or a subdomain, with no path, query, fragment or credentials; HTTP only for localhost.

Rust
use utopia_auth::passkeys::Origin;

let origin = Origin::new("example.com");
assert_eq!(origin.normalize(b"https://app.example.com:443"), Some("https://app.example.com".to_owned()));
assert_eq!(origin.normalize(b"http://app.example.com"), None);
Rust
pub const LOCALHOST: &str = "localhost"

The only host allowed over plain HTTP, when it is also the RP ID.

passkeys::tags

Own page

The CBOR tags the passkey decoder knows: the checks each makes on its content and what it decodes to. Unknown tags decode to their content.