Authorization Models: RBAC, ABAC, ReBAC and Zanzibar-Style Permissions
A B2B project tool launches with three roles: admin, member, viewer. Eighteen months later the roles table has 1,140 rows. There is “Viewer (EU, no billing)”, “Member (can export, cannot delete)”, and 212 roles whose names start with “Custom - “ followed by a customer name. Nobody can say what “Member v2 legacy” grants, and an enterprise customer’s security questionnaire asks a simple question: “Can a contractor in folder A ever see documents in folder B?” The honest answer is “we would have to read the code”.
Then a support ticket lands. A user removed a former employee from a shared folder, then uploaded a salary spreadsheet into it. For about four seconds the former employee could still open the new file, because the permission check hit a read replica that had not yet seen the removal.
Both problems are authorization problems, and neither is solved by better login. Authentication told you who the caller is. This article is about the harder half: deciding, millions of times a second, whether that caller may do this action to this resource, and getting the same answer everywhere.
What it is
An authorization model is the shape of the data and rules you use to answer one question: can(subject, action, resource). The subject is a user, a service or an API key. The action is a verb such as read, edit or delete. The resource is a specific object, such as document 8812.
There are four mainstream models, and real systems mix them:
- ACL (access control list): each resource stores the list of subjects allowed to act on it. Simple and precise, painful to manage in bulk.
- RBAC (role-based access control): subjects get roles, roles carry permissions. Easy to audit, coarse.
- ABAC (attribute-based access control): a policy evaluates attributes of the subject, resource, action and environment at request time. Very expressive, harder to reason about.
- ReBAC (relationship-based access control): permissions follow a graph of relationships, such as “editor of the folder that contains this document”. This is the model behind Google Zanzibar.
The second half of the design is where the decision is made (the policy decision point, PDP) and where it is enforced (the policy enforcement point, PEP). A gateway, a service, a database and a UI can all be enforcement points. Only some of them have enough context to decide.
How it works
ACLs
An ACL attaches (subject, permission) pairs to each object. File systems, S3 bucket ACLs and early document tools work this way. A check is a lookup on the object, which is fast. The trouble is bulk change: “give the whole finance team access to every Q3 folder” means writing thousands of entries, and “what can Bob access?” means scanning every object. AWS now recommends disabling S3 ACLs and using bucket policies instead, which is a hint about how ACLs age.
RBAC
RBAC inserts an indirection: users are assigned roles, roles are granted permissions. NIST formalised the model in the early 2000s and most enterprise software ships some form of it. A check becomes “does any role this user holds in this scope grant invoice:approve?”. Roles are scoped, usually per tenant and sometimes per project, so the real tuple is (user, role, scope).
RBAC’s strength is auditability. A compliance reviewer can read the role matrix. Its weakness is role explosion: every new dimension (region, department, data sensitivity, ownership) multiplies the role count. Three base roles times five regions times four departments is already 60 roles, and ownership (“can edit documents I created”) cannot be expressed as a role at all because it depends on the specific resource.
ABAC
ABAC replaces “which role do you have” with “do the facts of this request satisfy a policy”. A rule might read: allow read on a document if the user’s department equals the document’s department, the document’s classification is not restricted, and the request comes from a managed device. AWS IAM condition keys and tag-based policies are ABAC. So is most of what people write in a policy engine.
ABAC kills role explosion because the dimensions live in attributes, not role names. The price is that answering “who can see document X?” requires evaluating the policy against every user, and attribute data has to be fresh and trustworthy at decision time. A stale department attribute in a JWT is a stale permission.
ReBAC and Google Zanzibar
ReBAC stores relationships as data and derives permissions by walking them. Google described its global system, Zanzibar, in a 2019 USENIX ATC paper. It serves authorization for products such as Drive, Calendar, Cloud and YouTube, and the paper reports more than two trillion relation tuples, millions of checks per second, 95th percentile latency under 10 ms and availability above 99.999%.
The core data unit is a relation tuple: object#relation@subject. Some examples:
doc:roadmap#owner@user:alice
doc:roadmap#parent@folder:planning
folder:planning#editor@group:eng#member
group:eng#member@user:bob
The subject of a tuple can itself be a set (group:eng#member), which is how groups nest. A namespace configuration (the schema) defines how relations compose, for example “every owner is an editor, every editor is a viewer, and viewers of the parent folder are viewers of the document”. This is called a userset rewrite.
The main API is Check: “is user:bob a viewer of doc:roadmap?”. Zanzibar answers it by expanding the rewrite rules into a graph walk: viewer includes editor, editor includes the folder’s editors, the folder’s editors include group:eng#member, and Bob is a member. Other APIs are Read (list tuples), Write, Expand (show the full userset tree) and Watch (stream tuple changes so other systems can build indexes).
flowchart LR B["user:bob"] -->|"member"| G["group:eng"] G -->|"editor (via group member set)"| F["folder:planning"] F -->|"parent"| D["doc:roadmap"] A["user:alice"] -->|"owner"| D D -.->|"viewer = owner + editor + parent viewer"| Q["Check: bob viewer of doc:roadmap?<br/>Answer: allowed"] style B fill:#E1F5EE,stroke:#0F6E56,color:#085041 style A fill:#E1F5EE,stroke:#0F6E56,color:#085041 style G fill:#EEEDFE,stroke:#534AB7,color:#3C3489 style F fill:#EEEDFE,stroke:#534AB7,color:#3C3489 style D fill:#EEEDFE,stroke:#534AB7,color:#3C3489 style Q fill:#F1EFE8,stroke:#888780,color:#444441
Zookies and the new enemy problem
The opening support ticket has a name in the Zanzibar paper: the new enemy problem. If an ACL change and a content change are applied in the wrong order relative to a check, a user who was just removed can see content added after the removal. The paper gives two forms: ignoring the order of an ACL change and a content change, and evaluating a check against a stale snapshot of the ACLs.
Zanzibar’s fix is the zookie, an opaque consistency token. When a client changes content, it asks Zanzibar for a content-change check and receives a zookie that encodes a timestamp (Zanzibar is built on Spanner, which gives globally ordered commit timestamps). The client stores the zookie next to the content version. Later checks for that content pass the zookie, and Zanzibar guarantees the answer is evaluated at a snapshot at least as fresh as that timestamp. Most checks can then be served from a slightly stale, heavily cached snapshot, while the ones that matter are guaranteed to see the removal. If you want the theory behind “at least as fresh as”, it is a session guarantee from consistency models.
sequenceDiagram participant Admin as Folder admin participant App as Docs service participant Z as Authz service participant Ex as Ex-employee Admin->>Z: Write: remove ex-employee from folder Z-->>Admin: ok (commit time T1) Admin->>App: Upload salary.xlsx App->>Z: Content change check, get token Z-->>App: zookie at T2 (after T1) App->>App: Store zookie with doc version Ex->>App: Open salary.xlsx App->>Z: Check viewer, at least as fresh as zookie T2 Z-->>App: denied (snapshot includes the removal)
Open source Zanzibar-style systems
You no longer need to build this yourself. As of late 2026:
- OpenFGA started at Auth0 (Okta) and moved to CNCF incubation in October 2025. It uses a compact modelling language and supports contextual tuples and conditions for ABAC-style rules.
- SpiceDB from AuthZed is Apache 2.0 licensed and the most literal Zanzibar implementation, including ZedTokens (its zookies) and a choice of consistency per request.
- Permify is an open source Zanzibar-inspired service that FusionAuth acquired in November 2025.
All three give you Check, write, list-objects and list-subjects style APIs and run on Postgres or similar stores. None of them gives you Spanner, so read their docs on how they implement consistency tokens before relying on them for the new enemy case.
Policy engines: OPA and Cedar
A policy engine is a PDP that evaluates rules written as code. It does not store your relationship graph; you pass the facts in.
- Open Policy Agent (OPA) is a CNCF graduated project with the Rego language. It is popular for Kubernetes admission control (via Gatekeeper), API authorization sidecars and CI policy checks. OPA 1.0 made the newer Rego v1 syntax the default.
- Cedar is an open source language from AWS, designed to be analysable: tools can prove properties such as “no policy permits deleting a locked record”. It powers Amazon Verified Permissions, a managed PDP, and joined the CNCF as a sandbox project in October 2025.
permit (
principal,
action == Action::"edit",
resource
)
when { resource.owner == principal || principal in resource.editors }
unless { resource.locked };
The practical split: use a Zanzibar-style store when permissions are data that users change all day (sharing, groups, folders). Use a policy engine when permissions are rules that engineers change through review (compliance, environment checks, admission control). Many teams use both: ReBAC for “is Bob related to this doc”, a policy for “and only from a managed device during an approved session”.
Where it breaks
Role explosion and role drift. Roles get created for one customer and never deleted. Run a quarterly report of roles with fewer than five members and permissions nobody has used in 90 days. If your role names encode attributes (“EU”, “no billing”), you needed ABAC.
Stale tokens as permissions. Putting roles or group lists in a JWT makes checks free, and makes revocation slow: a 15 minute token means up to 15 minutes of access after removal. Keep coarse, slowly changing claims (tenant id, plan) in the token and fetch fine-grained permissions at decision time.
List filtering. Check answers “can I see this one?”. A search page needs “which of these 10,000 can I see?”. Checking each is slow, and filtering after pagination returns pages with 3 results. Use the engine’s list-objects API, pre-filter by tenant in the query, or build a permission-aware index from the Watch stream. This is where most ReBAC rollouts struggle.
Confused deputy. Service A has broad permissions and calls service B on behalf of a user. If B checks only that the caller is A, any user can reach anything A can. Propagate the end user (for example via OAuth token exchange) and check the user, not just the calling service.
Caching decisions unsafely. Caching allow for 5 minutes reintroduces the new enemy problem. Safe options, in order of preference: cache intermediate graph results (group membership) rather than final decisions; key the cache by the snapshot or consistency token; keep TTLs short (seconds) and invalidate on tuple changes from the Watch stream; never cache allow longer than you would accept a removed user keeping access. The general patterns are in cache patterns.
Fail open. When the PDP times out, the easy code path returns true. Authorization must fail closed, with a tight timeout and a clear error, and the PDP must be engineered to the same availability as the services that depend on it, because it now sits on every request path.
Multi-tenancy isolation
In a shared-database SaaS, the most damaging authorization bug is cross-tenant access. The rule is tenant id everywhere: in the token, in every table’s primary key or a leading index column, in every cache key, in every object storage prefix and in every log line.
Defence in depth is Postgres row-level security:
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
ALTER TABLE documents FORCE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON documents
USING (tenant_id = current_setting('app.tenant_id')::uuid);
-- per request, inside the transaction:
SET LOCAL app.tenant_id = '4f1c...';
Three gotchas. Table owners bypass RLS unless you use FORCE ROW LEVEL SECURITY, and superusers and roles with BYPASSRLS always bypass it, so the application must connect as an ordinary role. With a transaction-mode connection pooler, use SET LOCAL inside the transaction so one request’s tenant does not leak into the next. And RLS is a safety net, not the model: you still check per-object permissions in the service. For the largest tenants, separate schemas, databases or cells give stronger isolation at higher cost.
Real-world systems
- Google Zanzibar is the reference ReBAC system, described in the 2019 paper; it is internal to Google.
- AWS IAM combines RBAC-like roles with ABAC conditions and tags, evaluated by a policy engine on every API call; explicit deny wins over allow.
- Kubernetes RBAC uses Roles and ClusterRoles bound to users, groups and service accounts, and admission controllers such as OPA Gatekeeper or Kyverno add policy checks.
- OpenFGA, SpiceDB and Permify are the open source Zanzibar-style services described above.
- Amazon Verified Permissions is a managed Cedar PDP; OPA is the common self-hosted policy engine.
- Postgres ships row-level security; Supabase relies on it as the main tenant and user isolation mechanism for its client APIs.
How to apply it
| Need | Model | Typical tool |
|---|---|---|
| Internal admin tool, few fixed roles | RBAC | Roles table in your DB |
| Rules depend on region, department, device, time | ABAC | OPA, Cedar, IAM conditions |
| User-driven sharing, folders, groups, orgs | ReBAC | OpenFGA, SpiceDB, Permify |
| Compliance guardrails reviewed as code | Policy as code | OPA, Cedar |
| SaaS tenant isolation | Tenant id plus RLS | Postgres RLS, per-tenant cells |
Where to enforce. Split the job:
- At the API gateway: coarse checks only. Is the token valid, is the tenant active, does the caller have the scope for this route family. The gateway does not know who owns document 8812.
- In the service: fine-grained checks with resource ids, through a shared library or sidecar that calls the PDP. This is the decision that matters.
- In the database: tenant isolation as a backstop (RLS).
- In the UI: hide buttons for usability, never as security.
flowchart LR C["Client"] --> GW["API gateway<br/>token valid, tenant, scope"] GW --> S["Docs service<br/>PEP"] S -->|"check(user, edit, doc:8812)"| P["PDP<br/>OpenFGA / Cedar"] P -->|"allow / deny"| S S --> DB["Postgres<br/>RLS by tenant_id"] S -->|"decision log"| L["Audit log"] style GW fill:#F1EFE8,stroke:#888780,color:#444441 style S fill:#EEEDFE,stroke:#534AB7,color:#3C3489 style P fill:#EEEDFE,stroke:#534AB7,color:#3C3489 style DB fill:#E1F5EE,stroke:#0F6E56,color:#085041 style L fill:#FAEEDA,stroke:#854F0B,color:#633806
Audit every decision that matters. Log subject, action, resource, decision, the policy or tuple path that produced it, and the snapshot or policy version. “Who had access to this file on 3 March?” is a question you will be asked after an incident, and only decision logs plus tuple history can answer it. Ship them through your normal pipeline (covered in logs, metrics and traces) and keep them immutable.
Checklist:
- Default deny, fail closed, explicit deny overrides allow.
- One PDP API, called from a shared library, not ad hoc
ifstatements in 40 services. - Tenant id in every key, every query, every cache entry.
- Permissions tested like code: unit tests for policies, and property tests such as “no user outside tenant T can read any object in T”.
- Decision caching keyed by consistency token or kept to seconds.
Interview questions
Q1: Your RBAC system has 900 roles. How do you fix it without breaking customers?
Model answer: First measure. Export role-to-permission and user-to-role mappings, cluster roles by their effective permission sets, and find duplicates and roles with no users. Then identify the dimensions hidden in role names (region, department, ownership) and move those into attributes or relationships. Keep a small set of base roles and express the rest as ABAC conditions or ReBAC relations evaluated by one PDP. Migrate with a shadow mode: evaluate the new model alongside the old one on live traffic, log every disagreement, fix the model until disagreements are zero, then switch enforcement. Never change effective access silently for an enterprise customer.
Q2: Design authorization for a Google Docs style product.
Model answer: Model documents, folders, users, groups and organisations as objects, and store sharing as relation tuples: owner, editor, commenter, viewer, and parent for hierarchy. Define rewrite rules so that owner implies editor implies commenter implies viewer, and viewers of a parent are viewers of children. Serve Check from an authorization service with an index for group membership. Writes return a consistency token stored with the document version; checks on recently modified documents pass it so a removed user cannot see newly added content. For list pages use a list-objects API or a permission-aware search index fed by the change stream. Enforce in the document service, back tenant isolation with RLS, and log every decision.
Q3: Can you cache authorization decisions?
Model answer: Yes, carefully. Caching a final allow for minutes means a removed user keeps access for minutes, which is the new enemy problem. Prefer caching intermediate results such as group membership, invalidated from the tuple change stream. If you cache final decisions, key them by a snapshot or consistency token so a newer token misses the cache, and keep TTLs in seconds. Never cache across tenants, and always fail closed when the authorization service is unavailable rather than serving stale allows indefinitely.
✅ Key takeaways
- ACLs are per object, RBAC groups permissions into roles, ABAC evaluates attributes at request time, and ReBAC derives permissions from a relationship graph. Real systems combine them.
- Role explosion is the signal that attributes or relationships are hiding inside role names.
- Zanzibar stores relation tuples, answers Check by walking userset rewrites, and uses zookies so checks are at least as fresh as the content they protect, which prevents the new enemy problem.
- Use OpenFGA, SpiceDB or Permify for permissions as data, and OPA or Cedar for permissions as reviewed rules.
- Enforce coarse checks at the gateway, fine-grained checks in the service, and tenant isolation in the database with row-level security.
- Fail closed, cache membership rather than decisions, and log every decision with the reason.
🧠 Check your understanding
0 / 4-
1An engineer adds a role called 'Editor (EU, own documents only)'. What does this most strongly suggest?
Region is an attribute and ownership is a relationship to a specific resource, neither of which RBAC expresses well. Adding regional roles is the tempting fix, but it multiplies roles and is exactly how role explosion starts.
-
2In Zanzibar, what problem do zookies primarily solve?
A zookie encodes a timestamp so the check sees every ACL change committed before the content change. It is not an authentication token; authentication happens before Zanzibar is called.
-
3Your Postgres app uses row-level security for tenant isolation, but a test shows one tenant reading another's rows. The app connects as the table owner. What is the likely cause?
By default the owning role is exempt from its table's RLS policies. Use FORCE ROW LEVEL SECURITY and connect as a non-owner role without BYPASSRLS. RLS applies to SELECT as well as writes, so the first option is wrong.
-
4Where should the check 'may Bob edit document 8812' be enforced?
Fine-grained decisions need resource context that only the owning service has. The gateway is tempting because it sees all traffic, but it should do coarse checks such as token validity, tenant and scope.
Where to go next
- mTLS and workload identity: authorization between services starts with knowing which service is calling, which is what workload identity provides.
- Secrets management and encryption: the keys and credentials your authorization service and databases depend on.
- JWT architecture: what to put in a token and what to look up at decision time.
- Cell-based architecture: physical tenant isolation when row-level security is not enough.
Finished this lesson?
Mark it complete to track your progress across the roadmap.