Enforces absolute data boundaries between tenants in shared schema via RLS policies on tenant_id.
100
100%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Enforces absolute data boundaries between tenants in a shared-schema architecture using Postgres Row Level Security policies keyed on tenant_id.
This tile creates four RLS policies (SELECT, INSERT, UPDATE, DELETE) on a target table. Each policy extracts the tenant_id claim from the caller's JWT via auth.jwt() -> 'app_metadata' ->> 'tenant_id' and matches it against the row's tenant_id column. No row is ever visible or writable across tenant boundaries.
auth.jwt() -> 'app_metadata' ->> 'tenant_id'This expression is embedded in every policy's USING and WITH CHECK clause.
| Column | Type | Constraint |
|---|---|---|
| tenant_id | uuid | NOT NULL |
SELECT policyname, cmd, qual, with_check
FROM pg_policies
WHERE tablename = '<table>';SELECT relrowsecurity FROM pg_class WHERE relname = '<table>';tenant_id into JWT app_metadata. Without this hook, all policy checks fail with NULL comparison.custom-access-token-hook is deployed.