Security model

Ipseity is an identity service, so secrets are handled with the same rigour as the rest of the platform. This page covers encryption at rest, signing keys, network posture, hardening choices, and the audit trail. For RBAC/authorization details see identity.md and realms.md.

Console realm boundaries

Each realm has a protected public console client and a /realms/<realm> login URL; the default realm also has the root alias. Console API paths require the verified token realm to match the URL realm before resolving identities or performing CRUD. Tenant tokens cannot switch realms by header. The full realm directory and selector require ipseity.super in the main realm; ordinary metadata lists only the caller's realm. Privilege checks precede target-realm existence checks to avoid exposing a directory through error responses.

The browser keeps realm sessions and pending PKCE state in separate storage keys, verifies token realm/audience against the page, and revalidates stored sessions before rendering. Default-root and explicit main-realm aliases share one session. This prevents accidental cross-realm session reuse; URL paths on a shared host do not create separate browser origins. Public login names are guessable, and this model does not claim to eliminate every existence/timing side channel. See console.md for the complete access model.

When API audience enforcement is configured, the issuing realm's own managed console audience is accepted in addition to IPSEITY_API_AUDIENCE. Other realms' console audiences do not bypass that check. Managed client IDs are reserved and cannot be registered or mutated by tenant admins. First-run bootstrap is limited to the main console; tenant tokens never inherit bootstrap bypasses, and public closed-bootstrap status contains no entity counts.

Encryption at rest (AES-256-GCM)

Secret field values are encrypted at rest with AES-256-GCM (app/encryption.py):

  • Encrypted values are stored as ipseity-enc$v1$<nonce>$<ciphertext>.
  • Encrypted fields (only these):
    • principals: password, mfa_secret
    • clients: client_secret
  • Identifiers (name, client_id, groups, roles, permissions, email, etc.) are never encrypted, so they remain queryable/sortable.
  • Ciphertext is bound to its entity, record name, and field via associated data (AAD), preventing cut-and-paste substitution of an encrypted secret from one record into another.
  • KV, auth-code and refresh-token ConfigMap payloads are also encrypted at rest when the Kubernetes backends are in use.

Encryption key provisioning

The AES key resolves with this precedence:

  1. Config: IPSEITY_ENCRYPTION_KEY_FILE, then IPSEITY_ENCRYPTION_KEY.
  2. Kubernetes Secret IPSEITY_ENCRYPTION_KEY_SECRET_NAME (default ipseity-encryption-key), data key encryption.key = base64 of the 32-byte key.
  3. If Kubernetes is available, generate a 32-byte key and create the Secret (first writer wins; existing Secrets are never overwritten). This applies to fresh bootstrap and upgrades alike (enabling automatic migration of seed plaintext values on first read).
  4. Otherwise (memory/dev) an ephemeral in-process key is used.

If IPSEITY_ENCRYPTION_KEY(FILE) is set but can't be loaded, startup fails closed — it never silently falls back to an ephemeral key.

Back up the encryption-key Secret. Losing it makes existing encrypted secret values unreadable. See backup-and-recovery.md.

Signing keys (tokens)

  • Default algorithm is RS256 (IPSEITY_OIDC_SIGNING_ALG); per-realm keys and rotation require RS256. HS256 remains as a legacy single-key mode.
  • Each realm owns an RS256 key with a unique kid; the ipseity realm may use an env-configured PEM (IPSEITY_OIDC_SIGNING_PRIVATE_KEY_PEM/_FILE), otherwise keys persist in per-realm Kubernetes Secrets.
  • Retired (rotated) keys are kept (up to IPSEITY_OIDC_JWKS_RETIRED_KEYS) in the shared /oidc/jwks so tokens remain verifiable across rotation.
  • Rotation: on demand via POST /api/realms/<realm>/rotate-signing-key (ipseity.super), or scheduled via IPSEITY_OIDC_KEY_ROTATION_DAYS.
  • The public JWKS never exposes secret material; HS256 publishes no keys.

Back up the signing-key Secret(s) for stable token verification and to keep clients validating during rotation. See backup-and-recovery.md.

Network & transport

  • TLS is expected to terminate at your ingress/load balancer (see orbit-deploy.md); Ipseity serves HTTP internally.
  • CORS: SPA public clients should list origins in allowed_origins to get cross-origin access from a specific set of origins (exact match, or * for any origin). Cross-origin /oauth/* POSTs verify the request Origin against the client when allowed_origins is set; an empty/absent list means no origin restriction (backward compatible with pre-CORS clients; no CORS headers are emitted). Non-browser clients (no Origin) are unaffected.
  • Rate limiting: optional per-IP / per-client sliding window on /oauth/authorize and /oauth/token (429 on exceed). Complements the per-principal lockout.

Authentication hardening

  • Cross-realm memberships explicitly grant tenant-local roles to main-realm identities. Home credentials/MFA/lockout and login remain authoritative, while home RBAC is excluded. Membership identity bindings are checked throughout OAuth/token/API use; memberships cannot grant ipseity.super. Revocation affects online validation, not offline JWTs or an application's independent session cookie.

  • Passwords: PBKDF2-SHA256, configurable iterations (IPSEITY_PBKDF2_ITERATIONS, default 600000). Plaintext legacy values are migrated to hashed on successful login.

  • Optional TOTP MFA per principal (mfa_enabled + mfa_secret).

  • Per-principal lockout: IPSEITY_AUTH_MAX_ATTEMPTS failures within IPSEITY_AUTH_FAIL_WINDOW_SECONDS → locked for IPSEITY_AUTH_LOCKOUT_SECONDS (KV-backed, shared across replicas).

  • The login permission gates authentication; removing it blacklists the account from every source (see identity.md).

Bootstrap

First-run bootstrap is intentionally narrow and temporary. When no principals and no externally managed clients exist:

  • GET /api/bootstrap/status and /api/meta are public.
  • Unauthenticated mutations are limited to roles/groups CRUD and one-time POST /api/bootstrap/admin.
  • Bootstrap closes automatically once a principal or (external) client exists.
  • For network-exposed deployments, set IPSEITY_BOOTSTRAP_TOKEN so bootstrap mutations require a matching X-Bootstrap-Token header.

See bootstrap and GitOps.

Request hardening

  • Maximum request body size enforced (IPSEITY_MAX_REQUEST_BODY_BYTES).
  • HTML escaping on all reflected UI values (the console renders only server-escaped data).
  • JSON error responses; no stack traces leaked to clients.

Audit trail

Security-relevant events are emitted to stdout as AUDIT followed by one JSON object. Each event carries ts, realm, event_type, actor, status, remote_addr and details; embedded newlines are JSON-escaped. Output is flushed immediately and serialized across realm stores. Logs include identity data such as actor names, IP addresses and email addresses; configure access and retention in Loki. These log lines are not encrypted with the ConfigMap field cipher.

GET /api/audit (admin.audit.read) returns the serving process's per-realm cache (capped by IPSEITY_AUDIT_MAX_EVENTS, empty after restart). The cache limit does not limit log output. See monitoring for collection, retention and upgrade details. Core event types:

  • auth.login (ok/failed/locked), auth.consent (approve/deny)
  • auth.extlogin.* (initiate/callback/provision)
  • email.verify.send / email.verify.confirm
  • account.* (password.change, mfa.enroll/confirm/reset, provider.unlink, sessions.revoke)
  • api.upsert / api.put / api.delete / api.client.rotate-secret
  • oauth.token / oauth.introspect / oauth.revoke
  • oidc.logout / oidc.backchannel_logout
  • realm.create / realm.delete / realm.rotate-signing-key
  • bootstrap.admin.create

Audit writes never fail the request (failures are logged to stderr).

What is shared across replicas vs per-process

  • Shared (Kubernetes): entity data, revocation KV, lockout/login-attempt KV, consent/email/extension state, signing + encryption keys.
  • Per-process: the in-memory storage backend (dev only), the revocation negative cache, recent audit-event caches, and the rate-limit counters (documented as best-effort). Audit history is aggregated externally in Loki.