Where should tenant access be enforced?
Enforce record access in the database as well as the application. PostgreSQL row security can restrict the rows a role reads or changes. When row security is enabled without an applicable policy, access defaults to denial. Table owners normally bypass these policies; privileged roles need separate consideration. PostgreSQL explains the model.
Supabase combines PostgreSQL policies with authenticated user context. Its guide explains policies for reads and writes, and why service credentials must stay out of browsers. Read the Supabase guide.
Model membership before writing a policy
Our recommended starting point is a membership relation between a user and an organisation. Decide who can invite members, change roles, and remove access. Write those rules down before implementing a dashboard: otherwise the visual role picker can become the accidental specification for your security model.
An organisation identifier supplied by a browser is a requested scope, not proof that the caller belongs to it. Resolve that relationship through trusted identity and membership data.
Test access through the public API
Create two test organisations and separate users in an isolated environment. For each operation, keep an expected result:
- A member can read the records intended for their own organisation.
- The same member cannot read another organisation's known record identifier.
- An update cannot move a record into an organisation the user cannot access.
- Removing membership removes subsequent access.
- An unauthenticated request receives only deliberately public data.
Repeat these checks through the API credentials the frontend actually uses. Testing only a database owner's session can hide the very policy boundary you meant to verify.
Keep privileged paths explicit
Administrative jobs, exports, and support tools deserve their own checks and audit trail. Our rule of thumb is to document why each privileged operation needs broader access and what limits its scope. This makes the exception reviewable when the product grows.
Source review: 15 November 2026. This is an editorial guide based on the linked documentation, not a report of client results.