Skip to main content

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 a type and a globally unique id. A resource can optionally point to a parent.
You register resources with createResource. The engine validates that the parent exists before accepting a child.
Deleting a resource cascades: all child resources and their relationships are removed.

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: So if you’re an 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 has inheritFromParent 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 passing permissionRules to the config:
You can also limit which permissions inherit by passing an array:

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. Use subjectType: 'agent' with the agent’s ID:
This works with the existing KavachOS permission system. Use ReBAC for resource-level authorization and the existing kavach_permissions table for tool/action-level authorization.

Depth limiting

The maxDepth 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

KavachOS ReBAC is opinionated toward the common hierarchy pattern (org > workspace > project > resource) with sensible defaults. Zanzibar and SpiceDB are more general but require you to write a schema DSL. WorkOS FGA is SaaS-only.
Last modified on April 17, 2026