Realms and per-realm signing keys

Ipseity can operate multiple realms on a single deployment. A realm is a Kubernetes namespace that scopes all ipseity data for that realm: principals, groups, roles, clients, OAuth authorization codes, refresh tokens, revocation state and login lockouts. Audit log lines carry the realm name, and each process keeps a separate recent-event cache per realm. Clients, principals and RBAC remain realm-local. Explicit tenant memberships allow a main-realm identity to authenticate into a customer realm using only that tenant's assigned roles and groups; home permissions are never imported.

The ipseity realm

IPSEITY_NAMESPACE (default ipseity) is the ipseity realm. It always participates and is special in three ways:

  • POST /api/bootstrap/admin and the bootstrap flow provision the initial administrator here.
  • The main internal UI client (ipseity-internal) lives here; other realms receive their own protected console clients automatically.
  • The ipseity.super permission may only be granted to principals in the ipseity realm, and the ipseity-admin-platform role — which carries ipseity.super — only exists in the ipseity realm.

In a single-realm deployment nothing changes: the ipseity realm behaves exactly as Ipseity always has.

Discovering realms

Realms are discovered in two ways:

  1. Kubernetes (default). Every namespace that carries the IPSEITY_REALM_LABEL label (default ipseity.io/realm) is an additional realm, named after the namespace. The ipseity realm is always included, so no label is needed on IPSEITY_NAMESPACE. A realm namespace may be shared with the user's own applications — ipseity simply stores its realm data, labels and Secrets alongside the application's resources.
  2. Explicit list. Set IPSEITY_REALMS to a comma-separated list of realm names to override discovery entirely. This is also what local/in-memory (dev) mode uses, since there are no namespaces to label. The ipseity realm is always prepended if not listed.

Discovery is cached in-process for 30 seconds (config list is always fresh), so a newly labelled namespace appears without a restart. The ClusterRole (see orbit-deployment/default/010-rbac.yaml) must allow get/list/watch on namespaces for discovery to work.

Routing requests to realms

There is one issuer and one set of shared OAuth/OIDC endpoints. Consoles use /realms/<realm-name> (with an optional trailing slash). / and the explicit main-realm URL (/realms/ipseity by default) share their client and session. See console access for automatic clients, login and isolation.

  • OAuth/OIDC flows are routed by client_id. Client IDs are unique system-wide: Ipseity looks the client up across all realms and executes the whole flow (authorize → token → introspect/revoke/userinfo/logout) inside the owning realm. Each internal console client resolves only to its owning realm.
  • API access is routed by the realm claim embedded in access tokens. A token issued in realm whose principal is alice only ever reaches alice's identity data through /api/*.
  • Console API aliases /realms/<realm>/api/* additionally require the token realm to match the URL realm. The unprefixed API remains available.
  • Cross-realm administration. A principal in the ipseity realm granted ipseity.super may operate in any other realm by sending the target realm in the X-Ipseity-Realm request header from the main console. Without ipseity.super, sending this header is rejected with 403.

Ordinary tenant administrators receive only their own realm in /api/meta and cannot list other realms. The realm directory and cross-realm console selector are available only to main-realm super administrators. Realm-local administrators can log into their own console and manage entities using local permissions; ordinary users can log in for Account self-service without identity read access.

Managing realms

To let an existing main-realm account sign into a customer application, create a membership in the customer's namespace and sign in as ipseity/username. ipseity.super by itself only enables cross-realm administration; it does not grant customer-application login.

Realms are Kubernetes namespaces, and a super principal (ipseity.super in the ipseity realm) can manage them without touching kubectl:

  • GET /api/realms — list every realm with counts, bootstrap state and signing key summary.
  • GET /api/realms/<realm> — detail for one realm.
  • POST /api/realms with {"name": "<realm>"} — create a realm. On Kubernetes, Ipseity creates a namespace labelled IPSEITY_REALM_LABEL and provisions its default RBAC + signing key. Tolerant of existing namespaces: if a namespace with that name already exists (e.g. seeded by GitOps or shared with an application), Ipseity adopts it — it merges in the realm label and managed labels, and preserves the existing objects and non-Ipseity labels rather than failing with a conflict. In memory/dev mode the realm is added to the local registry.
  • DELETE /api/realms/<realm> — release a realm by default (see below).
  • DELETE /api/realms/<realm>?purge=true — purge a realm (see below) — the namespace and everything inside it is deleted.
  • POST /api/realms/<realm>/rotate-signing-key — rotate that realm's signing key.

Release vs purge. Given a shared realm namespace, "delete" has two distinct meanings:

  • Release (default) — remove every Ipseity-managed object (its entity ConfigMaps, auth codes, refresh tokens, KV, legacy audit records and signing-key Secrets) and the realm label, so the namespace is released back to the tenant but the namespace itself (and any non-Ipseity workloads) is kept.
  • Purge (?purge=true) — delete the namespace itself and, transitively, everything inside it, including anything not related to Ipseity.

The ipseity realm itself can never be deleted or released. Audit history already collected in Loki follows Loki retention and is unaffected by realm deletion.

All of these require ipseity.super in the ipseity realm. The UI exposes a Realms page (visible only to super principals) with list, create, delete and rotate actions alongside the per-realm console selector. Each non-ipseity realm row offers Release (default; removes Ipseity objects and the label, keeps the namespace) and Purge (danger; deletes the namespace and everything in it).

RBAC and ipseity.super

Effective permissions are resolved as before (direct permissions, then roles → role permissions, then groups → group roles/permissions), always within the principal's home realm.

New permission: ipseity.super — allows the holder's granted permissions in all realms. It is not a wildcard: a super principal still needs, e.g., principals.write to write principals, but that permission is honoured in every realm, not just the home realm. It is therefore granted alongside the usual identity permissions.

Rules:

  • ipseity.super may only be assigned to principals in the ipseity realm (enforced on write; the ipseity-admin-platform role grants it).
  • ipseity-admin-platform exists only in the ipseity realm. Other realms receive the entity-admin roles (ipseity-admin-principals, -groups, -roles, -clients, -providers, -memberships) and the ipseity-admins group referencing them, but not the platform role.
  • Realm management API (GET /api/realms, GET /api/realms/<realm>, POST /api/realms/<realm>/rotate-signing-key) requires ipseity.super in the ipseity realm.

Per-realm signing keys, JWKS and rotation

Because each realm is a separate namespace, a single signing key would not isolate realms and would be an inadequate secret boundary. Instead:

  • Each realm has its own RS256 signing key with its own kid (derived from the public key, so it changes on rotation — kid rollover). Tokens for a realm are signed with that realm's active key and verify against the key selected by the JWT kid.
  • The single GET /oidc/jwks endpoint aggregates the active key plus up to IPSEITY_OIDC_JWKS_RETIRED_KEYS (default 2) recently retired keys for every realm, so a remote verifier can validate tokens from all realms and across rotations from one document.
  • Keys persist in a per-realm Secret: the ipseity realm uses IPSEITY_OIDC_SIGNING_SECRET_NAME (default ipseity-oidc-signing-key); other realms use <name>-<app>-<realm> in their own namespace. Data keys: private.pem (active) and private.<kid>.pem (retired, kept for verification).
  • For the ipseity realm only, an env-configured key (IPSEITY_OIDC_SIGNING_PRIVATE_KEY_PEM/_FILE) remains authoritative and is loaded at start (no auto-rotation for env-configured keys).
  • Rotation happens two ways:
    • On demand: POST /api/realms/<realm>/rotate-signing-key (requires ipseity.super). The old key is retired and persisted next to the new private.pem; already-issued tokens keep verifying.
    • Scheduled: set IPSEITY_OIDC_KEY_ROTATION_DAYS (default 0 = disabled) to auto-rotate a realm's key once its active key is older than that many days.
  • HS256 remains a legacy single-key mode for the whole deployment; per-realm keys and rotation require RS256 (IPSEITY_OIDC_SIGNING_ALG=RS256).

New configuration

Variable Default Purpose
IPSEITY_REALMS (empty) Comma-separated explicit realm list (overrides namespace discovery; required for memory/dev multi-realm).
IPSEITY_REALM_LABEL ipseity.io/realm Label marking a namespace as an additional realm.
IPSEITY_OIDC_JWKS_RETIRED_KEYS 2 Retired keys per realm kept in /oidc/jwks.
IPSEITY_OIDC_KEY_ROTATION_DAYS 0 Scheduled signing-key rotation interval (0 = disabled).

Health and observability

  • /healthz reports the datastore backends (any realm store shares them).
  • GET /api/realms (super) lists each realm with counts, bootstrap state and signing details (active_kid, ephemeral, retired kids).
  • /oidc/jwks lists every realm's active and retired public keys.