OAuth 2.0 / OpenID Connect protocol

This page documents the exact protocol surface Ipseity exposes: endpoints, grants, tokens, claims, scopes and discovery.

Discovery and keys

Tenant memberships use these same endpoints and clients. A qualified username (ipseity/adrian) authenticates the home account against an explicit tenant-local grant; issued tokens retain the tenant realm and local roles. See that guide for subject identifiers, identity-binding claims and revocation semantics.

  • Discovery — GET /oidc/.well-known/openid-configuration returns the standard document: issuer, authorization/token/introspection/revocation/ userinfo/end-session endpoints, JWKS URI, response types (code), subject type (public), signing algorithms, token-endpoint auth methods (client_secret_post, none), grant types, PKCE methods (S256), scopes, and front/back-channel logout support.
  • JWKS — GET /oidc/jwks returns every realm's active and (up to IPSEITY_OIDC_JWKS_RETIRED_KEYS) retired RSA public keys, keyed by kid.

Supported endpoints

Method Path Purpose
GET /oauth/authorize Renders the login form (or starts an external provider flow when external_provider is set), validates the request, and renders the consent screen when the client requires it.
POST /oauth/authorize Authenticates and, on success, redirects to the client with an authorization code (or to consent).
POST /oauth/authorize/consent Processes the consent decision (consent_token, `decision=approve
POST /oauth/token Exchanges codes, refresh tokens, or client credentials.
POST /oauth/introspect Introspects an access token (RFC 7662).
POST /oauth/revoke Revokes an access or refresh token (RFC 7009).
GET /oidc/userinfo Returns OIDC claims for a bearer token.
GET /oidc/logout Ends the user's sessions; performs single logout (see below).
GET /oidc/verify-email Email-verification confirmation link.
GET /oauth/extlogin/callback External IdP callback (see providers.md).

Scope model

Known scopes (GET /api/meta → known_scopes):

Scope Privilege
openid Required to negotiate an OIDC flow; yields the sub claim in id_token/userinfo.
profile Adds identity claims (name from display_name, plus given_name/family_name when set).
groups Adds the principal's groups in id_token/userinfo.
roles Adds roles, direct_roles, group_roles, permissions in id_token/userinfo.
email Adds email and email_verified.

A client's allowed_scopes restricts what may be requested. Requested scopes must be a subset of the client's allowed_scopes; otherwise the request is rejected.

Grants

Authorization code + PKCE (user login)

GET  /oauth/authorize?response_type=code&client_id=…&redirect_uri=…&scope=…&state=…&nonce=…&code_challenge=…&code_challenge_method=S256[&external_provider=…]
POST /oauth/authorize          (login form → bearer-less POST)
POST /oauth/authorize/consent  (only when required)
POST /oauth/token  grant_type=authorization_code&code=…&redirect_uri=…&code_verifier=…
  • PKCE S256 required; code_verifier is required at the token endpoint.
  • Redirect URIs must match the client's redirect_uris rules (see below).
  • On success the token response includes access_token, token_type, expires_in, scope, id_token, refresh_token, refresh_expires_in.
  • JSON (AJAX) login: when the POST /oauth/authorize request sends Accept: application/json (or X-Requested-With: XMLHttpRequest), the server returns the authorization code as JSON ({"code": …, "state": …}) with 200 instead of a 302 redirect. This lets a same-origin SPA (the identity console) complete the whole login cycle with fetch — no intermediate holding pages. Browser form posts without the JSON header keep the classic 302 on success. Browser navigation failures use 303 to return to the login form with an error and the original authorization inputs. JSON callers retain {"error": …} with the appropriate status. Token-endpoint failures explicitly requested as browser pages also redirect to login; ordinary API/token calls keep JSON. See browser login recovery.

Client credentials (machine-to-machine)

POST /oauth/token  grant_type=client_credentials&client_id=…&client_secret=…&scope=…
  • Authenticates the client (secret for confidential clients). Returns an access token (audience = the client id) without a refresh token.

Refresh token

POST /oauth/token  grant_type=refresh_token&refresh_token=…&client_id=…&client_secret=…&scope=…
  • Rotating: the presented refresh token is consumed and a new one (plus a new access token / id_token) is issued. A reused refresh token fails. Kubernetes deletes consumed/revoked refresh-token ConfigMaps immediately. A sweep on startup and every five minutes removes expired, revoked or malformed records across all realms, even without login traffic. Valid sessions remain for IPSEITY_REFRESH_TOKEN_TTL_SECONDS (default 30 days); repeated logins can therefore create multiple live sessions. Revoke unwanted sessions under Account.
  • Scope can be narrowed on refresh (never widened beyond the original).

Token endpoint authentication

Confidential clients authenticate with client_id + client_secret (client_secret_post). Public clients send no secret; sending one for a public client is rejected.

Introspection

POST /oauth/introspect with token=<…> (client-authenticated). Returns RFC 7662 fields (active, scope, client_id, token_type, exp, iat, sub, iss, aud, realm, jti, username, and the principal's RBAC claims when present). Audience mismatch, a revoked token, or a disabled principal report active: false.

Revocation

POST /oauth/revoke with token=<…> (client-authenticated). Revokes a refresh token or, for access tokens, records a jti revocation against the realm KV so a reused access token is rejected. Revocation is authoritative and shared across replicas (subject to the optional per-process cache TTL).

id_token / userinfo claims

id_token and userinfo emit standard OIDC claims filtered by the granted scopes. The sub claims is the principal name. sid is a per-session identifier (used by single logout). RFC-compliant checks (issuer, audience, expiry, signature) are applied when these tokens are consumed.

Single logout

  • RP-initiated logout: GET /oidc/logout?client_id=…&post_logout_redirect_uri=…&state=… (post_logout_redirect_uri must match the client's redirect rules) — see slo-consent-ratelimit.md.
  • With an id_token_hint, Ipseity identifies the principal, revokes all of its sessions, and notifies every client with an active session via backchannel_logout_uri (signed Back-Channel Logout token) and/or a front-channel iframe page (frontchannel_logout_uri).

When a client sets require_consent, the authorize flow stops at a consent screen that lists the client and requested scopes. Approve (recorded per principal+client for the refresh-token TTL) issues the code; deny redirects with error=access_denied&state=…. See slo-consent-ratelimit.md.

Redirect URI rules

redirect_uris (used for login and post_logout_redirect_uri) support:

  • exact URI — https://app.example.com/callback
  • prefix wildcard — https://app.example.com/callback.*
  • regex — re:https://app\\.example\\.com/callback(?:\\?.*)?
  • global wildcard — .* (matches everything; high risk, admin-managed)

CORS

Browser-based SPA public clients may call /oauth/token, /oauth/introspect and /oauth/revoke cross-origin only if the client's allowed_origins contains the request Origin (exact match; * permits any origin, and an empty/absent allowed_origins means no origin restriction). Preflight is answered for known origins; the actual POST enforces the specific client's origins. See clients.md.