The risk of delegating isolation to the application
A dealership stores data that matters: the real cost of a unit, its documents, a customer's reservation and the margin on a sale. In a product shared by several organizations, that data must always be kept apart, even when the team adds a report, an admin query or a new relationship.
Trusting that separation to every endpoint remembering to add organization_id seems reasonable until it isn't. It doesn't take bad intent; a query written in a hurry is enough. The defect isn't human: it's architectural, because it lets an oversight have consequences that are far too big.
Row Level Security as a data control
That's why Patio uses PostgreSQL Row Level Security. The database policies express which rows an organization can read or modify, while the application keeps responsibility for authenticating people and managing their roles. One layer doesn't replace the other: they work together.
RBAC answers what someone can do within their dealership. RLS answers a prior question: whether that row even belongs to their dealership. It is defense in depth applied to an everyday risk.
Organization context and least privilege
The important decision isn't just turning on a policy; it's keeping the tenant from traveling as an optional parameter throughout the application. The context is derived from the authenticated identity and set for the transaction before touching the data. That way, a query that forgot the filter still hits a barrier.
Support exceptions exist, but they must be explicit, audited and minimal. An invisible exception isn't flexibility: it's a door nobody is watching.
Identity
- Authenticated user
- Organization and role
Application
- RBAC by role
- Permissions by branch
Transaction
- Tenant context
- Least-privilege access
PostgreSQL
- Row Level Security
- Rows isolated per organization
The authenticated identity resolves the organization and the role. The application applies business permissions and the database restricts the available rows through Row Level Security.
Architecture principle: multi-tenant isolation must be verifiable at every layer and, above all, stay active when the application code makes a mistake.