Email: OIDC email claims, mail channel and verification

Ipseity can emit the standard OIDC email / email_verified claims, send verification email through a pluggable mail-send channel, and verify a principal's stored email address. External providers already key accounts on email; these claims make that identity portable and verifiable.

email scope and claims

  • A new email scope was added to KNOWN_SCOPES (alongside openid profile groups roles). Clients list it in allowed_scopes.
  • When a user grants email, the id_token and userinfo response include:
    • email — the principal's stored email (when set);
    • email_verified — true/false reflecting the stored verification state.
  • Without the scope (or for a principal with no email) neither claim is emitted, matching the spec ("email" is only returned when the value is trustworthy; a principal that never proved it reports `email_verified: false").

Mail-send channel (pluggable)

app/mailer.py provides a Mailer interface with three backends, chosen automatically or by IPSEITY_MAILER (smtp | console | noop):

Backend Selection Behaviour
SMTP IPSEITY_SMTP_HOST set, or forced real SMTP (STARTTLS or SSL) with optional auth
console else (dev default) prints the rendered message to stdout
noop IPSEITY_MAILER=noop discards (tests / mail disabled)

Configuration: IPSEITY_MAILER, IPSEITY_SMTP_HOST, IPSEITY_SMTP_PORT (default 587), IPSEITY_SMTP_USERNAME, IPSEITY_SMTP_PASSWORD, IPSEITY_SMTP_FROM (default ipseity@localhost), IPSEITY_SMTP_FROM_NAME (default Ipseity), IPSEITY_SMTP_STARTTLS (default true), IPSEITY_SMTP_SSL (default false). /healthz reports the active mailer backend.

Verification flow

  1. POST /api/email/verify/send (authenticated) sends a link to the principal's stored email. The authenticated principal may verify their own address; an authenticated principal targeting another principal requires principals.write.
  2. The mail contains GET /oidc/verify-email?token=<realm>__<token> (token TTL IPSEITY_MAIL_VERIFY_TTL_SECONDS, default 3600s). The link sets the principal's email_verified = true and returns a confirmation page.
  3. From then on the email/email_verified claims report true.

Invalid, expired or mismatched verification links opened in a browser return to the realm's login screen with a message to sign in and request another email. See login error recovery.

Verification tokens are single-use and stored in the realm's KV. A principal without a stored email gets 400 ("no email address to verify").

External providers

When an external provider asserts email_verified: true for the account email (in userinfo or id_token), Ipseity records it as verified on the local principal (auto-provision or existing account — never downgrades an already verified address). This means an externally verified email surfaces as email_verified: true in Ipseity's own tokens without a separate confirmation link.