multitenancy

command
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 8 Imported by: 0

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/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL