passkeys
ModuleWebAuthn 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;pub struct RelyingPartyThe relying party passkeys are bound to: its ID (a domain), display name and the exact origins allowed to run ceremonies.
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 pageThe 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 pagePasskey 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;pub struct CeremonyWebAuthn registration and sign-in for one relying party: discoverable credentials, required user verification, no attestation.
use utopia_auth::passkeys::ceremony::Challenge;pub struct ChallengeA started ceremony: options for the browser and the opaque state to keep until the credential comes back.
use utopia_auth::passkeys::ceremony::Counter;pub struct CounterThe 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;pub struct CredentialA verified passkey: the record to store and the identifier to find it by.
use utopia_auth::passkeys::ceremony::StrictCounter;pub struct StrictCounterThe strict signature counter policy: the counter must always increase.
pub const TIMEOUT: i64 = 300Seconds a ceremony stays valid.
passkeys::cose
Own pagePasskey public keys in COSE form (RFC 9052/9053), and the signature algorithms ceremonies accept: ES256 and RS256.
use utopia_auth::passkeys::cose::PublicKey;pub struct PublicKeyA passkey's public key: its normalized COSE_Key map.
use utopia_auth::passkeys::cose::Algorithm;pub enum AlgorithmA signature algorithm passkeys may use, offered to the browser in
pubKeyCredParams.
passkeys::origin
Own pageThe web origins allowed to run passkey ceremonies for a relying party.
use utopia_auth::passkeys::origin::Origin;pub struct OriginThe 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.
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);pub const LOCALHOST: &str = "localhost"The only host allowed over plain HTTP, when it is also the RP ID.