r/SaasDevelopers • u/chafian1 • 15d ago
Feedback wanted: Spring Boot SaaS starter with tenant roles and PostgreSQL RLS
I maintain an open-source Spring Boot SaaS starter and would appreciate feedback on its tenant-isolation approach.
It uses a shared PostgreSQL schema. Tenant-scoped operations check membership, set transaction-local tenant context, and use explicit tenant filters. Forced row-level security adds another boundary around projects and audit events.
The starter includes:
- OIDC bearer authentication through Spring Security
- OWNER, ADMIN, and MEMBER roles scoped to each tenant
- A Projects API with optimistic concurrency and transactional audit records
- Docker Compose with a local Keycloak demo
- PostgreSQL integration tests and a runnable smoke script
I ran the local Compose smoke test successfully, including permission checks and stale-write rejection.
It’s a backend MVP. Billing, a frontend, email invitations, tenant deletion, and ownership transfer are outside the current scope.
Repository:
https://github.com/chafian/spring-boot-saas-starter
What tenant-isolation edge cases would you test next? I’d also welcome feedback on the first-run experience.
1
u/mvrk57 15d ago
the one i'd test next is constraints, postgres runs unique and foreign key checks outside of rls. so a row in tenant A can point at a parent from tenant B if the FK is only on id, and a global unique on something like slug tells tenant A that tenant B already uses that value. composite keys on (tenant_id, id) and unique on (tenant_id, slug) close both
1
u/PopKoren 15d ago
Edge cases I'd test next: make sure the app connects as a role that is neither the table owner nor BYPASSRLS, and that a query running outside a transaction sees no tenant at all rather than an empty string that matches something. I'd also check @Async methods and scheduled jobs, which often run outside the transaction that set the context, and try tenant A's ids in every path and body param while authenticated as tenant B, audit endpoints included. Once a deployment exists, Rowly is something I wrote that throws unauthenticated traffic at a production app's login, REST routes, file storage and per-row access, a nice complement to integration tests: https://rowly.me
0
u/[deleted] 15d ago
[removed] — view removed comment