Skip to main content

Organizations (multi-tenancy)

One Archenstack deployment can serve many organizations (tenants) at once, with full isolation between them. Each org owns its own groups, roles, features, overrides, matrix version, and audit log — there's no shared, mutable policy state between two orgs, and neither can see or edit the other's.

This page explains the tenancy model. To wire it up in a specific backend — the resolver settings, the dev header, the org picker — see Wiring multi-tenancy. For the normative rules, see the specification's Organizations section.

Single-org is just multi-org with one tenant

If you never emit an org claim and run a single-tenant deployment, nothing about the model below changes for you — your app simply lives in one org (by default the reserved root org). Multi-tenancy is additive: the wire is byte-identical whether or not a deployment serves many orgs.

One deployment, many tenants​

An organization is a first-class entity identified by a slug (^[a-z][a-z0-9_-]*$, the same grammar as roles and groups). It carries a display label, an is_active flag, and an ordering hint. That's the whole tenant anchor — everything else in the model just gains an org dimension.

Every policy-bearing thing becomes one per org:

ConceptSingle-tenantMulti-tenant
Groups, roles, featuresone setone set per org
Overrides (the editable layer)one layerone layer per org
The matrix version stampone counterone counter per org
The compiled snapshotone snapshotone snapshot per org
The audit logone append-only logone append-only log per org
Superusers & aliasesglobalstrictly per org

Two orgs may each define a manager role and a reports.export feature. They never collide and never resolve against each other — an override, alias, or group reference can never bridge two orgs.

Snapshot-per-org: the one idea that makes isolation fall out​

Here's the design in a sentence: an org selects which snapshot a caller loads and resolves — it is never an input to the resolver itself.

A MatrixSnapshot already is exactly one self-contained policy world. So isolation isn't a new rule bolted onto resolution; it's a consequence of handing the resolver the right snapshot:

The resolution algorithm — precedence, aliases, superusers, scopes, the authorizer — is byte-for-byte unchanged. decide(feature, role) still takes bare role and feature strings and evaluates them against the one org snapshot it was handed. Org never enters the canonical, hashed snapshot body; it travels out-of-band as transport metadata. That's why multi-tenancy landed additively, with wire_version still 1.

Why this matters for correctness

Because each org's rows compile into their own snapshot, the resolver never even sees a foreign org's entity. Cross-tenant leakage isn't something the resolution kernel has to prevent — there's no shared state for it to leak. The only place isolation must be actively defended is the caches: every snapshot/decision cache key embeds the org, so org A's cached matrix (or a cached allowed = true) can never be served to org B.

Per-org uniqueness​

Slugs and keys are unique per org, not globally:

  • roles and groups are unique on (org, slug);
  • features are unique on (org, key);
  • an override is unique on (org, feature, role).

The slug/feature-key grammar is unchanged — org is a first-class dimension, never encoded as a slug prefix or a dotted-namespace hack. Two orgs owning the same manager slug is normal and correct.

One practical consequence in the admin UI: a "this slug already exists" 409 is now per org. Creating manager in org B succeeds even though org A already has one. See per-org uniqueness in the spec.

Per-org anti-lockout​

The anti-lockout invariant — at least one active, standard role must resolve rbac.manage at FULL — is enforced per organization. Because each org has its own snapshot, the authorizer’s check runs against exactly that org's matrix on every mutation. No org's edit can ever affect another org's management-FULL holders.

The management feature (rbac.manage) and its minimum level (FULL) stay the spec-pinned global constants — they're not per-org configurable. What's per-org is the invariant: every org must independently keep a rbac.manage-FULL standard holder, and every newly-provisioned org needs a lockout-safe baseline (a management-FULL standard role plus an active superuser). "≥1 active super per deployment" becomes ≥1 active super per org.

The reserved root org​

root is a reserved org slug with exactly two jobs:

  1. Migration backfill. When an existing single-tenant deployment gains tenancy, all its existing rows are backfilled into root, so nothing moves and the old policy keeps working.
  2. Dev / seed default. Local development and the seed command target root so a single-org app boots without emitting any org claim.

root is supplied by the ARCHENSTACK_RBAC_DEFAULT_ORG environment variable (there is no inline code default — an unset value fails loudly). It is never a runtime fallback: at request time, a caller's org comes only from their claim, never silently from root.

Missing or unknown org fails closed​

Tenancy is fail-closed, matching Archenstack's existing caller-must-have-a-role posture:

  • Missing org — the resolver yields no org (an unauthenticated or claim-less caller). Treated like a role-less caller: deny (NONE). /me/ and /check/ return the standard role-less surface. The runtime never substitutes root.
  • Unknown org — the claim names an org that doesn't exist (or a reference tries to bridge two orgs). The request is rejected with the unknown_org error and denied — never by compiling an empty matrix, never by falling back to another tenant.

So a misconfigured claim can only ever remove access, never grant it or cross a tenant boundary.

Where identity comes from: the OIDC claim contract​

Archenstack stays entirely out of authentication. It never validates a token, runs a login, or talks to an identity provider — it only reads the already-authenticated principal off the request and maps claims to (org, subject). Validating the JWT is the host's job:

The host's resource server verifies the token signature against the issuer's JWKS, and checks iss (config-pinned), aud, and exp/iat/nbf. Only then does Archenstack read the principal.

Against that authenticated principal, Archenstack reads two claims:

ClaimRole in Archenstack
subThe identity. A stable, opaque, issuer-unique subject id. Archenstack keys its per-(org, sub) role assignment on it.
org (plus optional orgs[])The active tenant. Which org's snapshot this request selects. orgs[] lists membership for a multi-org user; org is the active one for this request.

The org/orgs[] claims live behind a dedicated organization scope, so they're only emitted when requested — additive on the identity provider's side, and invisible to clients that never ask for them.

Two rules the contract pins down
  • Identity is sub, never email. Email is mutable and belongs to a person, not a stable principal — treat it as a display attribute only. Role assignments key on sub.
  • Roles are internal to archenstack-rbac. The identity provider supplies sub and org/orgs[] and nothing about app roles. Archenstack owns role definitions, the matrix, and the (org, sub) → role assignment. The provider never learns your application's roles — which keeps the two systems decoupled and lets one identity provider back many apps.

This is described purely as the standards contract — an org/orgs[] claim behind an organization scope, a stable opaque sub, JWKS-validated tokens. Any standards-compliant OIDC provider that can emit a custom claim behind a scope satisfies it; Archenstack names no specific product.

To turn the claim into a selected snapshot, each backend exposes an org resolver (the org-level counterpart of the identity resolver). That wiring — Django's SCOPE_ORG_RESOLVER, Java's RbacPrincipalResolver.resolveOrg, the web client's withOrg — is the subject of the next page.

See also​