Why ReBAC
Traditional RBAC assigns roles to users globally or per-org. That works until you need finer-grained questions like “can agent X view this specific document because it belongs to a project in a workspace where X is an editor?” RBAC flattens that into a single role check and loses the context. ReBAC models authorization as a graph. Subjects (users, agents, teams) connect to objects (orgs, workspaces, projects, documents) through typed relationships. Permission checks walk the graph, following direct relationships and parent-child inheritance. This is the same approach Google uses internally (Zanzibar) and what WorkOS FGA, Ory Keto, and SpiceDB implement. KavachOS ships a built-in ReBAC engine that works with agents as first-class subjects.Quick start
Resource hierarchy
Resources form a tree. Each resource has atype and a globally unique id. A resource can optionally point to a parent.
createResource. The engine validates that the parent exists before accepting a child.
Relationships
A relationship is a tuple:(subjectType, subjectId, relation, objectType, objectId). Subjects can be users, agents, teams, or any string type you define.
Permission checks
check answers “does this subject have this permission on this object?” It returns { allowed: boolean, path?: string[] } where path shows the traversal steps when access is granted.
The engine resolves permissions in two ways:
Implied relations
For each resource type, some relations imply others. The built-in rules:| Resource type | owner implies | editor implies | member implies |
|---|---|---|---|
| org | admin, editor, viewer, member | viewer | viewer |
| workspace | admin, editor, viewer, member | viewer | viewer |
| project | admin, editor, viewer, member | viewer | viewer |
| document | editor, viewer | viewer | - |
editor on a document, a check for viewer succeeds. If you’re an owner, both editor and viewer checks succeed.
Parent inheritance
When a resource type hasinheritFromParent enabled, the engine walks up the tree. If Alice is a viewer on workspace eng, she’s also a viewer on project api (a child of eng) and document spec (a grandchild).
This combines with implied relations. Alice as editor on workspace eng gets viewer access to everything underneath.
Custom permission rules
Override the defaults by passingpermissionRules to the config:
Listing and expansion
List objects
Find all objects of a type that a subject can access:List subjects
Find all subjects that have a permission on an object:Expand
Get all relationships for an entity (as both subject and object):Agent integration
Agents are first-class subjects. UsesubjectType: 'agent' with the agent’s ID:
kavach_permissions table for tool/action-level authorization.
Depth limiting
ThemaxDepth config caps how many parent hops the engine will traverse. Default is 10. Set it lower if your hierarchy is shallow and you want faster checks:
Comparison with alternatives
| Feature | KavachOS ReBAC | Google Zanzibar | SpiceDB | WorkOS FGA |
|---|---|---|---|---|
| Relationship tuples | Yes | Yes | Yes | Yes |
| Resource hierarchy | Built-in | Userland | Userland | Userland |
| Permission derivation | Config-driven | Schema DSL | Schema DSL | JSON model |
| Agent-first | Yes | No | No | No |
| Self-hosted | Yes | No | Yes | No |
| Depth limiting | Configurable | Internal | Internal | Internal |
| Database | SQLite/Postgres/MySQL | Spanner | CockroachDB/Postgres | Managed |