Skip to main content

rustlavel_webauthn/
lib.rs

1//! rustlavel-webauthn: passkeys, written on the W3C WebAuthn specification.
2//!
3//! A password is a shared secret: the server holds something that can be
4//! stolen from it, and the user types something that can be phished out of
5//! them. A passkey is neither. The authenticator keeps a private key that
6//! never leaves it, the server stores only the public half, and the signature
7//! covers the origin — so a convincing copy of your login page at a different
8//! address gets nothing, because the browser will not sign for it.
9//!
10//! That last property is the one worth the work. Every other second factor can
11//! be relayed by a good enough phishing page; this one cannot.
12//!
13//! Everything here is written from scratch except the signature verification.
14//! CBOR, COSE framing, the ceremonies, the challenge handling — all ours. The
15//! elliptic-curve maths is not, and should not be: a subtly wrong verifier
16//! accepts forged assertions, which is the single failure this package exists
17//! to prevent.
18
19pub mod authentication;
20pub mod cbor;
21pub mod ceremony;
22pub mod challenge;
23pub mod cose;
24pub mod credential;
25pub mod registration;
26
27/// The big-integer arithmetic RS256 needs. Public-key only — see the module.
28pub(crate) mod rsa;
29
30pub use cbor::Cbor;
31pub use cose::{CoseKey, SignatureAlgorithm};
32
33pub use ceremony::{
34    AttestedCredential, AuthenticatorAttachment, AuthenticatorData, AuthenticatorFlags, ClientData,
35    RelyingParty, ResidentKey, UserEntity, UserVerification,
36};
37pub use challenge::{
38    Ceremony, Challenge, ChallengeStore, MemoryChallengeStore, SharedChallengeStore,
39};
40pub use credential::{
41    Credential, CredentialStore, MemoryCredentialStore, SharedCredentialStore,
42};
43
44pub use authentication::{
45    Authentication, AuthenticationResponse, PublicKeyCredentialRequestOptions,
46};
47pub use registration::{
48    AttestationStatement, PublicKeyCredentialCreationOptions, Registration, RegistrationResponse,
49};
50
51pub use rustlavel_core::{Error, Json, Result};
52
53/// What a controller finishing either ceremony imports.
54pub mod prelude {
55    pub use crate::{
56        AttestationStatement, Authentication, AuthenticationResponse, Ceremony, Challenge,
57        ChallengeStore, Credential, CredentialStore, MemoryChallengeStore, MemoryCredentialStore,
58        Registration, RegistrationResponse, RelyingParty, ResidentKey, UserEntity,
59        UserVerification,
60    };
61}