RBAC done right: lessons from ten enterprise builds
Roles on the user table, permission checks in the UI, and an is_admin boolean are the three mistakes we find in almost every system we inherit. Here is the model that scales instead.

The is_admin boolean
Almost every system starts with a boolean on the user record. It is the fastest thing to write and the hardest thing to remove, because within a year there are six kinds of administrator and the flag means something different in each module.
Worse, a role stored on the same row the user can update is a privilege-escalation waiting for an unguarded endpoint. Roles belong in their own table with their own write rules, granted only by a privileged path.
Permissions, roles, and scope are three things
A permission is an atomic capability: view invoice, approve purchase order, export payroll. A role is a named bundle of permissions. Scope is where the role applies — this branch, this region, this project.
Collapsing scope into the role name produces the familiar explosion of RegionalManagerNorth, RegionalManagerSouth, and so on. Keep them orthogonal: a user holds a role within a scope.
- Permission checks reference permissions, never role names.
- Roles are configuration, not code — new roles should not require a deployment.
- Every grant is written to an immutable audit log with actor, subject, and time.
Enforce at the data layer
Hiding a button is user experience, not security. The authorization check must happen where the data is read and written — in row-level security policies or in a single server-side gate every query passes through.
We use a security-definer function that answers has_permission for the current user and call it from the database policies themselves, so a forgotten check in a new endpoint fails closed.
Make review possible
Access reviews fail when nobody can answer who can approve payments. Build the reverse index early: given a permission, list every user who holds it and why. That single screen turns a quarterly scramble into a fifteen-minute task and catches the accumulated grants that audits always find.
Key takeaways
- Never store roles on the user or profile record — use a separate roles table.
- Check permissions server-side, at the data layer, on every request.
- Model permissions, group them into roles, and let scope be a separate dimension.
Working on something similar?
Talk it through with a senior engineer — no sales script, no obligation.
Request a free consultation