Security

Security and isolation

Guarantees

  1. Identification failures deny the request; they do not silently run as central unless you deliberately omit identification middleware.
  2. After Initialize, default database queries use the tenant pool. Central access requires tenancy.Central(ctx).
  3. Cache keys, storage paths, session prefixes, and queue tenant metadata are namespaced by tenant id.
  4. Storage helpers reject .. path segments.
  5. Hostnames are lowercased and validated; Origin identification parses a URL host rather than trusting raw strings blindly.
  6. Tenant pools are closed when a tenant is deleted through DeleteTenant / teardown.
  7. BelongsToTenant errors 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 × processes must stay under the database server’s limit.
  • Herd aliases: local-only (APP_ENV allow-list + Herd detection). They rewrite hostnames onto .test for 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.