DOCS / FEATURES
Magic links
Existing accounts can sign in without a password by asking for a link by
email. The link carries a single-use token that lasts 15 minutes, and
two-factor is still enforced when it's redeemed. Code: api/src/auth/magic_link.rs, the service functions
request_magic_link / sign_in_with_magic_link in
api/src/auth/service.rs, and web/src/features/auth/MagicLink*.tsx.
Flow
POST /api/auth/magic-linkwith{email}always answers 202, whether or not the account exists, so the endpoint can't be used to discover accounts (an address at a domain that requires single sign-on gets403 sso_requiredinstead). For an existing account it queues anemail.magic_linkjob.- The job mints a single-use token (
email_tokenspurposemagic_link, 15 minutes) and emailsAPP_URL/magic?token=…. It re-checks the account at send time: a disabled account gets nothing. - The SPA's
/magicpage posts the token toPOST /api/auth/magic-link/verifywith{token, mode}.
What redeeming does
- The token is consumed, so a second use fails.
- A disabled account is refused, as on the other sign-in paths.
- Following the link proves the inbox, so the address is marked verified (and the welcome email goes out the first time).
- Two-factor still applies. A TOTP-enabled account gets
{"two_factor_required": true, "challenge_token": …}instead of credentials, finished withPOST /api/auth/2faexactly like a password login. A magic link replaces the password, not the second factor.
Magic links sign in existing accounts only. New users register first. The
/auth rate limit (burst 10, then one per second per IP) applies to both
endpoints.