TenantLayer
Open-source Java library that enforces multi-tenant data isolation at the database level, so one customer's data can never leak into another's by accident.
🔗 Visit TenantLayerDescription
Imagine an apartment building where every tenant is supposed to have their own locked door, but the lock only works if the front desk remembers to check everyone's room number on the way in. That's how most software built for multiple customers at once (a "multi-tenant" app) actually keeps data separate: a line of application code that has to run correctly, every single time, in every code path, or one customer's data quietly leaks into another's dashboard. TenantLayer moves that lock down to the building's foundation instead of leaving it at the front desk.
TenantLayer is an open-source Java library for Spring Boot applications that enforces tenant isolation using PostgreSQL's row-level security, so a forgotten or misplaced tenant filter in application code can no longer leak another customer's rows — the database itself refuses the query. It resolves the current tenant from request headers, subdomains, or JWT claims, and keeps that tenant context correctly attached across async operations, virtual threads, and scheduled background jobs, which is exactly where hand-rolled tenant-filtering code tends to silently break. The project ships with 101 tests run against real infrastructure, plus testing utilities specifically built to catch isolation leaks before they reach production.
💬 Our review
The short version: if you run a Spring Boot + PostgreSQL SaaS and have ever worried a bug could let Customer A see Customer B's data, TenantLayer moves that guarantee from "hope the code is right everywhere" to "the database enforces it" — the price is being tied to PostgreSQL and to a v0.1.0 API that isn't stable yet.
There's no direct like-for-like open-source competitor at exactly this level — most teams hand-roll tenant filters with Hibernate discriminators, bolt tenant checks onto Spring Security manually, or reach for a heavier identity platform like Keycloak, which solves authentication but not row-level data isolation. TenantLayer's real selling point is narrow and well-executed: it specifically targets async/background-job tenant-context loss, the exact spot where hand-rolled implementations tend to break under load. Being open-source and free removes the cost question entirely; the real cost is engineering time to adopt it and the risk of building on a pre-1.0 API that may still change. For a team already on Spring Boot + PostgreSQL shipping a real multi-tenant product, it's worth evaluating now, with the caveat to pin versions carefully until v1.0 lands.
📊 Global score
🤖 AI-enriched data
Gratuit et open source (auto-hébergé), aucun coût de licence.
Pros
Isolation appliquée au niveau base de données (row-level security), évite les fuites silencieuses entre clients
Le contexte tenant se propage correctement à travers l'async, les virtual threads et les jobs planifiés
Couverture de tests conséquente (101 tests) et utilitaires de test dédiés à l'isolation
Corrige six vulnérabilités multi-tenancy documentées via des patterns intégrés
Cons
v0.1.0 — l'API peut encore changer avant la v1.0
Spécifique à PostgreSQL, pas neutre vis-à-vis du SGBD
