Security
Security and isolation
Guarantees
- Identification failures deny the request; they do not silently run as central unless you deliberately omit identification middleware.
- After
Initialize, default database queries use the tenant pool. Central access requirestenancy.Central(ctx). - Cache keys, storage paths, session prefixes, and queue tenant metadata are namespaced by tenant id.
- Storage helpers reject
..path segments. - Hostnames are lowercased and validated; Origin identification parses a URL host rather than trusting raw strings blindly.
- Tenant pools are closed when a tenant is deleted through
DeleteTenant/ teardown. BelongsToTenanterrors if there is no tenant in context (fail-closed).
Threat notes
- Host headers: prefer deploying behind a trusted proxy configuration
provided by Laravel Go / your platform. Domain middleware uses
Request.Hostname(). - Header identification (
X-Tenant): only use on trusted API clients; prefer domain or path identification for browser apps. - Resolver cache: enable only when you also invalidate on tenant/domain
updates (
identification.InvalidateTenant). - Connection budget:
MaxConnectionsPerTenant × tenants × processesmust stay under the database server’s limit. - Herd aliases: local-only (
APP_ENVallow-list + Herd detection). They rewrite hostnames onto.testfor developer convenience and do not run in production environments by default. See Herd.
Testing isolation
See Testing and the package’s security_test.go for cross-tenant
read/write checks.