tenantlayer.io

TenantLayer documentation

Start with Getting started. Read Row-level security before you deploy anything.

GuideWhat it answers
Getting startedAdding the dependency and getting isolation in ten minutes
Row-level securityHow isolation is actually enforced, and the three mistakes that quietly break it
Isolation strategiesDiscriminator column vs RLS, and why you want both
Tenant resolutionHeaders, subdomains, paths, JWT claims, and precedence
Securing resolutionWhy a header alone is not enough, and how to close that
Context propagation@Async, CompletableFuture, virtual threads, scheduled jobs, HTTP, Kafka
The tenant registryWho your tenants are, and running work for each of them
TestingFixtures, assertions, and how to tell a real isolation test from a vacuous one
Context storageThreadLocal today, ScopedValue later
Configuration referenceEvery property
ArchitectureHow the pieces fit together, and why the obvious alternatives are wrong
Adopting in an existing appGetting there from a running system, without a flag day
TroubleshootingIt returns nothing · the policy is not applying · the tenant is null

The one-paragraph version

Postgres already has row-level security. TenantLayer does not reinvent it — the database does the enforcing, which is exactly why it is trustworthy. What TenantLayer does is the wiring around it: getting the tenant onto the connection at the right moment, guaranteeing it is cleared when the connection returns to the pool, carrying it across every thread and network boundary in between, failing closed when it is absent, and giving you a test that proves all of that rather than a README that claims it.