Skip to main content

Zanzibar Relationship Checks

Check authorization using Google Zanzibar-style relationship-based access control. Perfect for hierarchical resources, sharing models, and complex permission inheritance.

POST /api/v1/zanzibar/check

How Zanzibar Checks Work

Unlike simple permission checks that ask "does this user have permission X?", Zanzibar checks ask:

note

LumoAuth traverses the relationship graph to answer this question, following inheritance rules and computed relationships.

Request Format

FieldTypeRequiredDescription
objectstringYesResource being accessed (namespace:id)
relationstringYesType of access (e.g., viewer, editor, owner)
userstringYesSubject requesting access (namespace:id or namespace:id#relation)

Basic Example

curl -X POST https://api.example.com/api/v1/zanzibar/check \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"object": "document:annual-report",
"relation": "editor",
"user": "user:alice"
}'
{
"allowed": true,
"object": "document:annual-report",
"relation": "editor",
"user": "user:alice"
}

Understanding the Format

Objects

Objects are resources in your system. Format: namespace:id

ExampleMeaning
document:readmeA document with ID "readme"
folder:projectsA folder named "projects"
organization:acmeOrganization "acme"
repository:myappA repository named "myapp"

Relations

Relations define the type of access or connection. Common relations include:

RelationTypical UseUsually Implies
ownerFull control over a resourceeditor, viewer
editorCan modify a resourceviewer
viewerRead-only access
memberBelongs to a group/orgviewer (of group resources)
adminAdministrative accessowner, member
parentHierarchical containmentPermission inheritance

Subjects (Users)

Subjects are entities requesting access. They can be:

FormatExampleMeaning
namespace:iduser:aliceA specific user
namespace:id#relationteam:engineering#memberAll members of the engineering team
namespace:id#relationorganization:acme#adminAll admins of the Acme org

Advanced: Userset Subjects

The power of Zanzibar comes from usersets – checking access through group membership.

Example: Team-Based Access

Suppose you have these relationships stored:

curl -X POST https://api.example.com/api/v1/zanzibar/check \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"object": "document:api-docs",
"relation": "viewer",
"user": "user:bob"
}'

LumoAuth will return allowed: true because:

  1. Bob is a member of team:engineering
  2. team:engineering#member is a viewer of document:api-docs
  3. Therefore, Bob is a viewer of document:api-docs

Real-World Examples

Example 1: Document Sharing (Google Docs Style)

# Can Carol view the Q4 report?
curl -X POST https://api.example.com/api/v1/zanzibar/check \
-d '{"object": "document:q4-report", "relation": "viewer", "user": "user:carol"}'
# Result: allowed: true (Carol is on finance team, which has viewer access)

# Can Carol edit the Q4 report?
curl -X POST https://api.example.com/api/v1/zanzibar/check \
-d '{"object": "document:q4-report", "relation": "editor", "user": "user:carol"}'
# Result: allowed: false (Carol only has view access via team membership)

Example 2: Folder Hierarchy

# Can Alice view the readme?
curl -X POST https://api.example.com/api/v1/zanzibar/check \
-d '{"object": "document:readme", "relation": "viewer", "user": "user:alice"}'
# Result: allowed: true (Alice owns the parent folder)

Example 3: GitHub-Style Repository Access

relationships

# Org structure
organization:acme#admin@user:ceo
organization:acme#member@user:developer

# Team in org
team:platform#parent@organization:acme
team:platform#member@user:developer

# Repo owned by team
repository:api-service#owner@team:platform#member

# Schema: org admins are admins of all repos
# Schema: team members who own a repo are maintainers

Comparison: Zanzibar vs RBAC

AspectRBAC CheckZanzibar Check
QuestionDoes user have permission?Does user have relation to object?
Exampledocument.editdocument:123#editor@user:456
Resource AwareNo (global permission)Yes (specific resource)
InheritanceRole hierarchy onlyObject + relation hierarchy
Best ForAdmin features, global actionsShared resources, hierarchies