DekEn

อัปเดต 2026-09-07

Multi-tenant organizations (Postgres RLS)

org-isolated data, app_rls role

Organizations isolate their data from each other using Postgres row-level security (RLS) enforced at the database layer, not just in application code — so a bug in a query can't leak one tenant's rows into another's.

เมื่อไรจึงใช้
  • You're setting up a second organization/team on a shared deployment
  • You're reviewing the security model behind a multi-tenant SaaS claim
  • You're debugging why a query returns fewer rows than expected in a tenant-scoped table
คำนวณอย่างไร

Every tenant-scoped table carries a tenant_node_id; the application connects as the non-superuser app_rls Postgres role with FORCE RLS policies enabled, so the database itself refuses cross-tenant rows even if application code forgets a WHERE clause.

ข้อควรระวัง
noteA Postgres superuser role bypasses FORCE RLS entirely — the isolation guarantee depends on the app always connecting as app_rls, never as a superuser; reverting that connection role silently defeats the whole model.
ที่เกี่ยวข้อง