Docs menuFeatures

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

  1. POST /api/auth/magic-link with {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 gets 403 sso_required instead). For an existing account it queues an email.magic_link job.
  2. The job mints a single-use token (email_tokens purpose magic_link, 15 minutes) and emails APP_URL/magic?token=…. It re-checks the account at send time: a disabled account gets nothing.
  3. The SPA's /magic page posts the token to POST /api/auth/magic-link/verify with {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 with POST /api/auth/2fa exactly 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.