pub struct Passkey { /* private fields */ }Expand description
The passkey plugin: .plugin(Passkey::new()).
The relying party defaults to the app: its ID is base_url’s host, its name the app name,
and ceremonies may come from base_url’s origin or any exact (wildcard-free) trusted
origin. Passkeys always require user verification (a PIN or biometric), as webauthn-rs
does for passkeys.
Implementations§
Source§impl Passkey
impl Passkey
pub fn new() -> Self
Sourcepub fn rp_id(self, rp_id: impl Into<String>) -> Self
pub fn rp_id(self, rp_id: impl Into<String>) -> Self
The relying party ID passkeys are bound to: a domain, e.g. acme.dk to share
passkeys between acme.dk and app.acme.dk. Default: base_url’s host.
Sourcepub fn rp_name(self, rp_name: impl Into<String>) -> Self
pub fn rp_name(self, rp_name: impl Into<String>) -> Self
The name authenticators show for the site. Default: the app name.
Sourcepub fn origin(self, origin: impl Into<String>) -> Self
pub fn origin(self, origin: impl Into<String>) -> Self
An origin ceremonies may come from, e.g. https://app.acme.dk. Call it once per
origin. Setting any replaces the default (base_url plus exact trusted origins).
Sourcepub fn sign_up<F, Fut>(self, resolve: F) -> Selfwhere
F: Fn(PasskeySignUp) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<PasskeyUser, AuthError>> + Send + 'static,
pub fn sign_up<F, Fut>(self, resolve: F) -> Selfwhere
F: Fn(PasskeySignUp) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<PasskeyUser, AuthError>> + Send + 'static,
Passkey-first sign-up, off by default: a signed-out visitor may register a passkey,
and registering it creates their user. resolve runs in
generate-register-options and decides who that user is, typically from the
context the client passed; an error it returns is the route’s answer. The user is
only created once verify-registration has checked the attestation, and with
createSession: true it signs in through the sign-in gates (method "passkey").
Better Auth’s registration: { requireSession: false, resolveUser }. Signed-in
users still register as before: a fresh session that may mint credentials.
use fastauth_core::prelude::*;
use fastauth_plugin_passkey::{Passkey, PasskeyUser};
let passkey = Passkey::new().sign_up(|request| async move {
let email = request.context.ok_or_else(|| {
AuthError::bad_request("INVALID_CONTEXT", "pass the email as context")
})?;
Ok(PasskeyUser { name: request.name.unwrap_or_default(), email, ..PasskeyUser::default() })
});Trait Implementations§
Source§impl Plugin for Passkey
impl Plugin for Passkey
Source§const ID: &'static str = "passkey"
const ID: &'static str = "passkey"
Source§type Requires = ()
type Requires = ()
(), (Organization,).Source§type UserFields = ()
type UserFields = ()
user; () for none.Source§type SessionFields = ()
type SessionFields = ()
session; () for none.Source§fn schema(&self, schema: &mut SchemaBuilder)
fn schema(&self, schema: &mut SchemaBuilder)
schema.model::<M>()) or columns. UserFields and SessionFields are
added automatically.