Expand description
Passwordless sign-in: one-time codes by email, passkeys, and sessions.
Auth::send_codeemails a 6-digit code (valid 10 minutes, 5 tries, at most 5 codes per address per 15 minutes);Auth::verify_codechecks it. The email address is the account.- Once signed in, a user can add a passkey (
Auth::passkey_register_startand_finish) and later sign in with it (Auth::passkey_login_startand_finish). - Either way the app creates a session (
Auth::create_session): an opaque token for a cookie or anAuthorization: Bearerheader, valid 30 days and renewed while used. Ending it (Auth::end_session) takes effect at once.
Only hashes of codes and tokens are stored. The tables (login_code,
session, passkey, auth_challenge) are defined in the project’s
first migration.
Settings: SMTP_URL (e.g. smtps://user:pass@smtp.example.com) and
MAIL_FROM send the codes; without SMTP_URL, debug builds log them
(and write them to MAIL_DIR, if set) instead. PASSKEY_RP_ID (default
localhost) is the domain passkeys belong to, shared by its subdomains;
PASSKEY_ORIGIN (default http://localhost:8000) is its web origin.
Structs§
- Auth
- Sign-in for one application. Cheap to clone.
- Challenge
- A passkey ceremony to finish in the browser:
optionsgo tonavigator.credentials(publicKey),idcomes back with the result. - Session
- A signed-in session.
Functions§
- normalize_
email emailtrimmed and lowercased, if it looks like an address.