Skip to Content
Signet

Passwordless verification

Proof lifecycle, expiry, replay, callbacks and error handling for passwordless sign-in.

This page describes what happens after a magic link or email OTP is sent. Both factors share the same Token store, session creation and error semantics.

The two proof kinds

KindIssued byStored formCarries data
TokenMagicLinktoken.Service.IssueWithDataSHA-256 digest of the raw tokenEmail, name, callback URL
TokenEmailOTPTokenStore.CreateTokenDigest(email + ":" + code)Nothing; the email is supplied at verification

Both kinds are in AllTokenKinds, so every revocation sweep — password change, reset, account deletion, refresh replay containment — includes them. Neither raw value is ever stored.

Expiry

Passwordless.MagicLinkTTL and Passwordless.OTPTTL default to five minutes and are validated by New; a negative value returns ErrInvalidPasswordlessConfig. Expiry uses the configured Clock, so tests can advance time deterministically. An expired proof returns ErrTokenExpired / invalid_token (401).

Single use and rotation

ConsumeToken is an atomic conditional update, and the digest comparison is constant time. Once consumed, a proof cannot be used again. Replaying a magic link returns ErrMagicLinkAlreadyUsed / link_already_used (401); replaying an OTP returns ErrOTPAlreadyUsed / code_already_used (401). A User who tries the same proof twice knows to request a new one.

Sending a second proof for the same email deletes the previous Token of that kind:

  • magic links: keyed by the User ID, or a deterministic proof subject before the User exists;
  • email OTPs: keyed the same way.

Only the newest code or link works. The older one fails as an unknown Token.

The callback embedded in the link is authoritative. If a query callback_url is present it must match the embedded value exactly. The callback must appear in one of these allowlists, in order:

  1. Passwordless.AllowedRedirects
  2. OAuth.AllowedRedirects
  3. AppURL exactly

Matching is exact; a same-origin but unlisted path is rejected with ErrOAuthRedirectNotAllowed / invalid_request (400). This is the same rule OAuth uses. Without a callback, verification returns session JSON instead of redirecting.

Email verification and auto-created Users

A consumed proof marks the email verified. For an existing User, EmailVerified is set to true and the password and all Sessions are left intact. For an unknown email:

  • AllowSignUp nil or true: a User is created with EmailVerified = true and no credential Account. They can set a password later with ChangePassword.
  • AllowSignUp = false: the send was a silent success with no proof, so verification cannot succeed.

OnSignUp is not called for passwordless auto-creation, so no hook receives personal data that it would not get from password sign-up.

Sessions

Verification creates a Session immediately through the same seam password sign-in uses. The idle and absolute timeouts come from SessionConfig. The Go API returns the raw Session token in SignInResult.SessionToken; the HTTP API sets the signet_session (or __Host- prefixed) cookie and the CSRF cookie. To require recent authentication afterwards, use VerifyFreshSession or RequireFreshSession — freshness is measured from CreatedAt.

Error reference

SituationSentinelWire
Malformed, unknown, rotated or expired magic linkErrInvalidMagicLink401 invalid_link
Magic link already consumedErrMagicLinkAlreadyUsed401 link_already_used
Malformed, unknown, wrong-email or expired OTPErrInvalidOTP401 invalid_code
OTP already consumedErrOTPAlreadyUsed401 code_already_used
Callback outside the allowlist or mismatchedErrOAuthRedirectNotAllowed400 invalid_request
Send or verify endpoint over its limitErrRateLimited429 rate_limited
Negative configured TTLErrInvalidPasswordlessConfigrejected by New
Invalid email addressErrInvalidEmail400 invalid_input

See Errors for the complete mapping and Security for the controls these flows share.

On this page