Notes
The question
Every authorization model answers the same question: may this subject perform this action on this resource? The subject is who, the action is what, the resource is the thing acted on, and the answer is allow or deny. The models differ only in how they decide. Role-based access control decides by the user's role. Attribute-based decides by attributes and rules. Relationship-based decides by relationships between the user and the resource. Whatever the model, it must be enforced on the server, on every request.
- subject (who) + action (what) + resource (on what) -> allow or deny
- the models differ in HOW they decide
- RBAC: by the user's role
- ABAC: by attributes and rules
- ReBAC: by relationships
- all must be enforced on the server, every request
RBAC
Role-based access control, RBAC, is the most common model. You group permissions into roles, such as admin, editor and viewer, and assign roles to users. The check is simply whether the user holds a role that permits the action. Simple, well understood and easy to audit, which is why most systems start here. Its weaknesses are role explosion, hundreds of fine-grained roles, and that it cannot naturally express rules like edit only your own records.
- permissions grouped into roles (admin, editor, viewer)
- users are assigned roles
- check: does the user have a role that permits this?
- simple, well understood, easy to audit
- weakness: role explosion, and it struggles with "only your own records"
ABAC
Attribute-based access control, ABAC, decides from attributes: of the user (department, clearance), the resource (owner, sensitivity), and the context (time, location, network). You write policies like allow if the user's department equals the resource's. It is flexible and fine-grained, expressing rules RBAC cannot. The cost is complexity: policies are harder to write, test and reason about, and you need tooling like Open Policy Agent with Rego, or Cedar.
- decide from attributes: user (dept, clearance), resource (owner, sensitivity), context (time, location)
- policy: allow if user.dept == resource.dept
- flexible, fine-grained
- cost: complex to write, test and reason about
- tools: OPA/Rego, Cedar
ReBAC
Relationship-based access control, ReBAC, decides from relationships: Alice owns this document, the document is in that folder, Bob is in that team. Permissions flow along the graph, so membership and nesting are inherited. This is how Google Docs sharing works, from Google's Zanzibar paper, and it is excellent for sharing, nested folders and teams. Implementations include SpiceDB, OpenFGA and Ory Keto. Many systems combine models: RBAC for coarse roles, ReBAC or ABAC for fine access.
- decide from relationships: "Alice is owner of doc1", "doc1 is in folder X", "Bob is a member of team Y"
- permissions flow along the graph (inheritance)
- this is how Google Docs sharing works (Zanzibar)
- great for sharing, nesting, teams; tools: SpiceDB, OpenFGA, Ory Keto
The bugs: IDOR
Now the bugs these models prevent, starting with the most common. An insecure direct object reference, IDOR: you change an order number in a URL from 123 to 124 and read someone else's order. The cause is code that checked you are logged in, not that the record is yours. Related is a missing function-level check, such as an admin endpoint with no role check. And hiding a button in the interface is not access control, because an attacker calls the API directly.
- IDOR: /orders/123 -> /124 reads someone else's order
- cause: code checks you are logged in, not that the record is yours
- missing function-level check: an admin API, no role check
- a hidden button is not a control: attackers call the API directly
The rules
The rules apply to every model. Deny by default and allow explicitly, so a forgotten check fails closed. Enforce on the server, every request and every object, never trusting the client. Check ownership, not just role, which stops IDOR. Centralise the logic rather than scattering checks through controllers. Apply least privilege to roles and service accounts. Log decisions. And test with negative cases: confirm that forbidden actions are actually forbidden.
- deny by default; allow explicitly
- enforce server-side, every request, every object
- check ownership, not just role (stops IDOR)
- centralise the logic
- least privilege for roles and service accounts
- log decisions; test negatives
Where to enforce it
Where you enforce authorization matters as much as the model. The mature pattern is a policy decision point: one place that answers allow or deny, so rules are not copy-pasted across services where they drift. Enforce at the API, and for defence in depth at the data layer too, such as row-level security so even a missed check cannot return another tenant's rows. In microservices, use a shared authz service or an Open Policy Agent sidecar, not rules reimplemented per service.
- a policy decision point: one place that answers allow/deny
- enforce at the API and, for defence in depth, at the data layer (row-level security)
- in microservices: a shared authz service or sidecar (OPA), not copy-pasted rules
- make the default path the safe one
Common mistakes
Mistakes. Checking that a user is authenticated but never that they are authorized for this object. A role check with no ownership check, the classic IDOR. Authorization enforced only in the interface. Checks scattered and inconsistent, so some paths are missed. Allowing by default, so a forgotten check fails open. Trusting a role or user id sent by the client instead of the session. And no negative tests, so nobody confirms the forbidden stays forbidden.
- checking authentication but not authorization
- role check without ownership check (IDOR)
- authorization only in the UI
- scattered, inconsistent checks
- allow by default; fail open
- trusting a client-sent role or user ID
- no negative tests
Say it like this
In the interview: RBAC for coarse roles because it is simple and auditable, ABAC when decisions depend on attributes and context, ReBAC for sharing, teams and nested resources, the Google Docs style. Real systems combine them. To avoid broken access control, especially IDOR, I check ownership of the specific object, not just the role, deny by default, and enforce on the server for every request and object. I centralise the logic in a policy decision point, apply least privilege, and write negative tests.
- "RBAC for coarse roles, ABAC
- for attribute and context
- rules, ReBAC for sharing and nesting like Google Docs.
- Many systems combine them. To avoid IDOR I check ownership, not just role, deny by default, enforce server-side
- on every object, centralise
- the logic, write negative tests."