Multi-Tenant Isolation
STOA implements a multi-layered tenant isolation model combining logical identity and data scoping in the Control Plane and Gateway (ADR-074, ADR-070) with optional Kubernetes namespace and CNI network boundaries for tenant workloads. This enables a single STOA deployment to serve multiple organizations without cross-tenant data leakage.
Tenant Data Modelβ
Each tenant in STOA has the following properties:
| Field | Type | Description |
|---|---|---|
id | string | Slug identifier (e.g., oasis, acme-corp) β immutable |
name | string | Display name (e.g., "OASIS Gunters") |
description | string | Optional description |
status | enum | active, suspended, archived |
settings | JSON | Quotas, feature flags, custom config |
created_at | timestamp | Creation date |
Tenant Status Lifecycleβ
- Active β Full access to all platform features
- Suspended β Read-only access, no API calls, no deployments. Used for billing issues or compliance holds.
- Archived β Data retained for audit, no access. Pending deletion per retention policy.
Five Isolation Layersβ
1. Kubernetes Namespace Isolationβ
In multi-tenant Kubernetes deployments, operators can place tenant workloads and Tool / ToolSet CRDs in dedicated namespaces with labels for policy enforcement (operator reference pattern; the gateway-only charts/stoa-platform chart does not auto-provision tenant namespaces):
apiVersion: v1
kind: Namespace
metadata:
name: tenant-acme
labels:
stoa.io/tenant-id: acme
stoa.io/tier: enterprise
pod-security.kubernetes.io/enforce: restricted
Resource quotas prevent a single tenant from consuming cluster resources:
apiVersion: v1
kind: ResourceQuota
metadata:
name: tenant-quota
namespace: tenant-acme
spec:
hard:
requests.cpu: "10"
requests.memory: 20Gi
persistentvolumeclaims: "5"
services.loadbalancers: "2"
2. Network Isolationβ
Network policies prevent cross-tenant communication at the CNI level:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: tenant-isolation
namespace: tenant-acme
spec:
podSelector: {}
policyTypes: [Ingress, Egress]
ingress:
- from:
- namespaceSelector:
matchLabels:
stoa.io/tenant-id: acme
egress:
- to:
- namespaceSelector:
matchLabels:
stoa.io/tenant-id: acme
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: stoa-system
Tenants can communicate with their own namespace and the shared stoa-system namespace (for the Control Plane API and Gateway), but never with other tenants.
3. Gateway Isolationβ
The STOA Gateway enforces tenant boundaries at the API and MCP layers:
- Fail-closed tenant policies β Signed Ed25519 per-tenant tool policy artifacts (
STOA_POLICY_BOOT_TENANTS, ADR-070) deny cross-tenant tool invocation if policy state is missing or invalid - Tenant-scoped routing & visibility β Each API and MCP tool (
stoa://tools/{name}) is scoped to a verifiedtenant_id - Separate rate limits β Per-tenant quota enforcement
- Independent policies β OPA policies evaluate tenant context
In multi-gateway deployments, the Control Plane's 6 gateway adapters (ADR-035) and the on-site stoa-connect (STOA Link) agent (Kong, Gravitee, webMethods, and explicit opt-in Envoy xDS) propagate tenant scoping to each target gateway.
4. Authentication Isolationβ
Per ADR-074 (which retires the earlier realm-per-tenant draft in ADR-026), STOA uses a single shared stoa Keycloak realm (KEYCLOAK_REALM=stoa) with group-based tenant membership:
- One top-level Keycloak group per tenant β Provisioned at
/<tenant_id>bysetup_tenant_group(TenantProvisioningService) during tenant creation (POST /v1/tenants), whileadd_user_to_tenantsets thetenant_iduser attribute mapped into the JWT - Verified
tenant_idJWT claim β Read from the JWT claims after RS256 JWKS signature and issuer verification (Claims::tenant_id()/require_tenantinstoa-gateway,get_current_userincontrol-plane-api); never trusted from unverified headers or query strings - Mandatory tenant-boundary enforcement β Control Plane RBAC (
require_tenant_access, and RustRbacEnforcerwhen theenforce_tenant_isolationRBAC policy field is enabled) rejects cross-tenant requests (403) unless the caller holdscpi-admin; MCPtools/listand Envoyext_authzgRPC require a verifiedtenant_idmatching the target tenant/route without presuming acpi-admincross-tenant bypass (whereas published UAC REST routes withjwt_validationinproxy/dynamic.rsvalidate the JWT and optionalinboundAuthAudiencefail-closed without comparing the token'stenant_idclaim toroute.tenant_id) - External IdP brokering β Multi-IdP federation is demonstrated only in separate demo realms (
deploy/docker-compose/profilefederation, not attested in the productionstoarealm import) rather than per-tenant realms
5. Data Isolationβ
- Shared PostgreSQL schema with
tenant_idscoping β All tenant-owned records (apis,subscriptions,consumers,mcp_servers, audit entries) carry an indexedtenant_idcolumn filtered by SQLAlchemy repository queries (no schema-per-tenant) - Encrypted secrets β Sensitive credentials are stored via the Vault HTTP API backend (OpenBao by default, ADR-075) or encrypted at rest
- Audit logging β Every control-plane and gateway access is logged with verified
tenant_idcontext
RBAC and Tenant Scopingβ
STOA's RBAC model combines platform-wide and tenant-scoped roles:
| Role | Scope | Permissions |
|---|---|---|
cpi-admin | Platform (Control Plane RBAC) | Cross-tenant administration in the Control Plane API (and Rust RbacEnforcer policy checks) |
tenant-admin | Tenant | Full access to own tenant only |
devops | Tenant | Deploy and promote within own tenant |
viewer | Tenant | Read-only access to own tenant |
Key behaviors:
- A
tenant-adminfor tenantacmecannot see tenantglobexresources - A
viewercan browse APIs and tools but cannot invoke, create, or modify - A
cpi-adminsees all tenants and can perform cross-tenant operations in Control Plane RBAC (require_tenant_access); data-plane checks on MCPtools/listand Envoyext_authzgRPC still require a verifiedtenant_idmatching the target tenant/route (while UAC RESTjwt_validationverifies the JWT and audience without comparing the token'stenant_idto the route) - Environment mode (dev/staging/prod) further restricts operations β production is read-only by default
Tenant Settingsβ
The settings JSON field on each tenant allows per-tenant configuration:
{
"quotas": {
"max_apis": 50,
"max_subscriptions": 200,
"max_rate_limit": 10000
},
"features": {
"mcp_enabled": true,
"shadow_mode": false,
"advanced_analytics": true
},
"notifications": {
"webhook_url": "https://hooks.acme.com/stoa",
"email_alerts": true
}
}
Tenant Tiersβ
| Tier | Resources | Features | SLA |
|---|---|---|---|
| Community | Limited | Core APIs, basic MCP | Best effort |
| Starter | Moderate | APIs + MCP tools, portal | 99% |
| Business | High | Full platform, multi-gateway | Per agreement |
| Enterprise | Custom | White-label, dedicated support | Custom SLA |
Per-Tenant Observabilityβ
Every metric in STOA is labeled with the tenant ID, enabling per-tenant dashboards:
- API request rates β
stoa_api_requests_total{tenant="acme"} - Error rates β
stoa_api_errors_total{tenant="acme"} - Latency percentiles β
stoa_api_duration_seconds{tenant="acme"} - Resource utilization β CPU, memory, storage per namespace
- Cost attribution β Per-tenant resource consumption for billing
Grafana dashboards can be filtered by tenant for tenant-admins, or viewed across all tenants for platform admins.
Relatedβ
- Architecture Overview β System architecture
- MCP Gateway β Gateway concepts
- Subscriptions Guide β API subscription management
- ADR-074: Single Keycloak Realm & Tenant Group Model β Tenant identity and PostgreSQL scoping
- ADR-070: Gateway Fail-Closed Posture β Signed per-tenant tool policy enforcement
- ADR-022: UAC Tenant Architecture β Architecture decision