Relationship-Based Access Control (ReBAC): The Zanzibar Model & Graph Authorization
Relationship-Based Access Control (ReBAC, pioneered by Google Zanzibar) models authorization as a directed graph of relationships between subjects, groups, and objects (tuples formatted as 'object#relation@subject'). Permissions are evaluated by traversing graph edges, supporting recursive group memberships and inherited object hierarchies.
user:alice#member@team:platform).Step 1: Security relations are stored as canonical relation tuples (Object, Relation, Subject).
In modern collaborative software (Google Docs, Figma, CosmosApp), access is not just based on roles or attributes, but on relationships: 'User A is a member of Team B, which has editor access on Folder C, which contains Document D'. Computing nested folder permissions and shared document links cannot be modeled cleanly with static RBAC or ABAC.
The Social Circle & Family Tree: You don't have a badge saying 'Allowed into Bob's Wedding'. You are allowed in because you are the 'sibling of Alice', and Alice is a 'friend of Bob'. The venue checks the chain of family and friend relationships.
[ Relation Tuple Store (Zanzibar Graph) ]
• (folder:marketing, parent, org:cosmos)
• (doc:q4_strategy, parent, folder:marketing)
• (folder:marketing, editor, team:growth)
• (team:growth, member, user:alice)
[ Question: Can user:alice EDIT doc:q4_strategy? ]
│
▼ (Graph Traversal Engine)
doc:q4_strategy ──(parent)──► folder:marketing ──(editor)──► team:growth ──(member)──► user:alice
│
▼ Graph path exists!
[ Decision: PERMIT ]CosmosApp allows users to nest documents within multi-level folder hierarchies and share items with cross-functional project teams. CosmosApp implements ReBAC with relation tuples. When Alice attempts to read a document in the 'Engineering' folder, CosmosApp's graph engine resolves Alice's membership in the 'DevOps' team and confirms inherited read permissions.
Step 1: Security relations are stored as canonical relation tuples (Object, Relation, Subject).
Step 2: Client requests an action on an object (e.g. check(doc:10, 'write', user:alice)).
Step 3: Graph engine checks for direct tuple existence: (doc:10, 'writer', user:alice).
Step 4: If not found directly, engine expands relations: checks if user:alice is a member of any group that has 'writer' access.
Step 5: Engine recursively traverses parent hierarchies (checking if doc:10 inherits from folder:5).
Step 6: If a valid path connects user to permission, returns Allow; otherwise Deny.
// CosmosApp ReBAC Relation Tuple Representation:
interface RelationTuple {
object: string; // e.g. "document:q4_plan"
relation: string; // e.g. "viewer"
subject: string; // e.g. "user:alice" or "team:finance#member"
}
export class SimpleZanzibarEngine {
private tuples: RelationTuple[] = [];
addTuple(tuple: RelationTuple) { this.tuples.push(tuple); }
async check(object: string, relation: string, user: string): Promise<boolean> {
// 1. Direct check
const direct = this.tuples.some(
(t) => t.object === object && t.relation === relation && t.subject === user
);
if (direct) return true;
// 2. Expand group memberships
const groups = this.tuples.filter((t) => t.object === object && t.relation === relation);
for (const g of groups) {
if (g.subject.includes('#')) {
const [groupObj, groupRel] = g.subject.split('#');
if (await this.check(groupObj, groupRel, user)) return true;
}
}
return false;
}
}- ✕ReBAC replaces all database joins (ReBAC is an authorization graph; domain business data remains in relational tables).
- ✕Graph traversal is too slow for real-time APIs (Modern Zanzibar engines like SpiceDB use indexed adjacency lists and concurrent edge evaluation to resolve checks in < 5ms).
Key Architectural Takeaways
- ✓ReBAC models authorization as a graph of relationships between users, groups, and resources.
- ✓Ideal for collaborative tools with nested resource hierarchies (workspaces, folders, documents).
- ✓Modern implementations (SpiceDB, Ory Keto) provide sub-5ms graph traversals with caching.
Writing endless recursive SQL CTE queries in application controllers to resolve folder hierarchies.
Adopt a dedicated relationship graph model or ReBAC engine (Zanzibar model) to isolate authorization graph traversals.
What is a 'relation tuple' in the Google Zanzibar / ReBAC authorization model?