ADR-002: Multi-Tenant Selection With Same API Key

Status: Accepted Date: 2026-02-22 Sprint: SPRINT_20260222_053_DOCS_multi_tenant_same_api_key_contract_baseline.md

This record defines the canonical contract — claims, client metadata, headers, and error semantics — for clients that belong to more than one tenant while reusing a single API key/client registration. Read it before touching tenant resolution in Authority, the gateway, or any downstream service.

Context

Stella Ops must support clients that are assigned to more than one tenant while still using the same API key/client registration. Existing behavior assumes a scalar tenant assignment (tenant) and cannot safely select among multiple tenant memberships.

Without a canonical contract, modules diverge on claim names, header behavior, default selection, and mismatch handling. This creates cross-tenant leakage risk and migration churn.

Decision

Use one selected tenant per access token, chosen at token issuance time.

Selected model (accepted)

  1. Client metadata supports both:
    • tenant (scalar compatibility/default tenant)
    • tenants (space-delimited assignment set; normalized lowercase, unique, sorted)
  2. Token request may include tenant=<id>.
  3. Authority resolves selected tenant deterministically:
    • If tenant parameter is present: it must exist in assigned tenants.
    • If no parameter:
      • use scalar tenant when configured, otherwise
      • use single-entry tenants, otherwise
      • reject as ambiguous.
  4. Issued tokens carry:
    • stellaops:tenant (selected tenant)
    • stellaops:allowed_tenants (space-delimited assigned set, optional)
  5. Gateway and services continue operating with one effective tenant per request.

Fallback model (rejected for default path)

Multi-tenant token + per-request header override (X-StellaOps-TenantId) as primary selector.

Reason rejected:

Canonical Contract

Claims

Client metadata

Headers

Error semantics

Threat Model

Header spoofing

Risk: caller supplies tenant headers to escalate into another tenant.
Mitigation: gateway strips inbound identity headers and rewrites from validated claims.

Token confusion

Risk: token tenant differs from issuing client assignment or persisted token document.
Mitigation: validation enforces principal/document/client assignment consistency.

Cross-tenant leakage

Risk: silent default tenant fallback routes tenant-scoped requests incorrectly.
Mitigation: remove authenticated "default" tenant fallback and fail ambiguous selections.

Consequences

Positive

Tradeoff

References