Documentation
¶
Overview ¶
Example: multitenancy demonstrates storage-level tenant isolation using storage.WithTenant. Two tenants ("acme" and "globex") share one logical agent and one SQLite store, yet neither can see the other's sessions — even when a caller tries to read another tenant's session by its exact id (the IDOR the control plane closes in production).
The key API is storage.WithTenant(ctx, tenantID): it stamps the tenant on every write and scopes every read. Callers that never set a tenant operate under storage.DefaultTenant, so single-tenant code keeps working unchanged.
In ChronosOS the tenant is derived from the authenticated principal (auth.UserClaims.TenantID) — never from a client-supplied id — so this isolation is enforced server-side. This example shows the storage primitive that guarantee is built on.
Runs fully offline (SQLite, no API keys):
go run ./examples/multitenancy/