>

How mature is your authorization? Take our free 2-minute assessment

[Take the Quiz]

RBAC vs ReBAC: When to use which

How RBAC and ReBAC manage permissions through roles versus relationships determines the best fit for a system's administrative simplicity and fine-grained authorization needs.

Role-based access control (RBAC) and relationship-based access control (ReBAC) represent two distinct philosophies for managing permissions. RBAC organizes access around user roles and their associated permissions, a familiar model for application permissions. ReBAC, in contrast, defines access through the relationships between users and resources, offering a more dynamic approach for collaborative and fine-grained authorization scenarios. Understanding their core mechanics, performance trade-offs, and ideal use cases is crucial for selecting the right model for a given system architecture.

What RBAC does

Role-based access control operates on a simple, indirect model of authorization. Instead of assigning permissions directly to users, the system assigns users to one or more roles. Each role is then granted a set of permissions to perform specific operations on certain types of objects. When a user attempts an action, the system checks if any of their assigned roles contain the necessary permission. This model, formalized by standards like ANSI INCITS 359-2004, simplifies administration by decoupling users from permissions, making it easier to manage access for large groups of users based on their job functions. Common patterns include hierarchical RBAC, where roles can inherit permissions from other roles, and constrained RBAC, which enforces policies like separation of duties. Implementations are widespread and can be found natively in platforms like Kubernetes and databases such as PostgreSQL, as well as in general-purpose policy engines.

How ReBAC differs

Relationship-based access control evaluates authorization requests by traversing a graph of relationships. Its fundamental data unit is the "relation tuple," which asserts a relationship between an object and a subject, such as document:budget#viewer@user:alice. The subject can also be another group of users, like document:budget#viewer@group:finance#member, enabling nested and inherited permissions. Authorization logic is defined in a schema which specifies how these relationships compose to grant permissions. For example, a schema might define that a document's editor is also implicitly a viewer, or that a user can access a file if they have access to its parent folder. This model, popularized by Google's Zanzibar paper, externalizes authorization data into a dedicated service that evaluates queries over this relationship graph. Engines like SpiceDB implement this pattern, providing APIs to check permissions, read relationships, and expand a permission to see exactly why it was granted.

Performance characteristics

The performance profiles of RBAC and ReBAC diverge based on their underlying data models. RBAC checks are typically simple lookups in user-role and role-permission tables. Its scaling challenges are usually more administrative than technical, emerging from the proliferation of roles as permission granularity increases. ReBAC performance, however, depends on the complexity and depth of the relationship graph. A check may require traversing many paths in the relationship graph, a process that can introduce latency. To mitigate this, ReBAC systems employ caching, query deduplication, and specialized indexes. A critical performance consideration for ReBAC is consistency. To prevent incorrect decisions based on stale data, especially in distributed environments, these systems use consistency tokens to ensure that permission checks are evaluated at a point in time no earlier than the last relevant data change. This mechanism prevents race conditions, such as the "new enemy problem," where a user's access is revoked but they can still access a resource due to replication lag.

When to choose RBAC

RBAC is an excellent choice when access patterns are stable and align closely with organizational structure or job functions. It excels in applications where permissions are coarse-grained and do not change frequently. For example, a system where users are categorized as administrators, auditors, or support_agents with clearly defined capabilities is a natural fit for RBAC. The model is also well-suited for environments with strict compliance requirements, as its support for static and dynamic separation of duties is mature and well-understood. Its widespread adoption means that tooling is ubiquitous and many engineers are already familiar with its concepts, reducing the learning curve for implementation and maintenance.

When ReBAC makes sense

ReBAC provides significant advantages in applications where permissions are dynamic, fine-grained, and driven by user interactions. It is the natural choice for collaborative platforms , project management tools, and enterprise SaaS products, where users have shared access to resources with other users or teams. The model elegantly handles complex scenarios such as nested groups, resource hierarchies like folders containing other folders, and delegated access permissions. Applications that need to answer questions like "who can access this resource and why?" benefit from ReBAC's ability to explain the chain of relationships that resulted in a permission grant. It is also ideal for multi-tenant systems that require sophisticated cross-tenant sharing and access control logic.

Combining both approaches

RBAC and ReBAC are not mutually exclusive and can be combined effectively in a hybrid architecture. A common pattern is to use RBAC for broad, application-level entitlements while employing ReBAC for fine-grained, resource-specific permissions. For instance, a user might be assigned an editor role via RBAC, which grants them access to the application's editing features. However, a ReBAC check would still determine whether they can edit a specific document based on direct sharing relationships. It is also possible to model RBAC concepts within a ReBAC system by treating roles as groups and role assignments as membership relationships. Furthermore, ReBAC systems can incorporate attribute-based conditions through features like caveats, allowing for policies that depend on contextual data like IP address or time of day, blending the strengths of all three major access control models.

Comparison table

FactorRole-Based Access Control (RBAC)Relationship-Based Access Control (ReBAC)
Data LocationTypically within the application database or an identity provider.Centralized in a dedicated authorization service or database.
PerformancePerformance degrades with role complexity.Latency depends on graph depth and width; relies on heavy caching.
Best Use CasesStable roles, coarse-grained permissions, SoD.Collaboration, fine-grained sharing, resource hierarchies, enterprise apps.
Query TypesDoes user have role? Does role have permission?Can subject perform action on resource?
Permission ChangesAdding or modifying roles and their static permission assignments.Adding relationship data. Modifying the schema that defines relations and permissions.
ConsistencyManaged by the underlying database's transaction guarantees.Can utilize consistency tokens to prevent stale reads.
Deployment ComplexityOften built into platforms; can be simple to start.Requires deploying and managing a specialized authorization service. Hosted services are also available.

FAQ

How do I migrate from an existing RBAC system to ReBAC?

A gradual migration is often the best approach. Start by identifying a feature that suffers from RBAC's limitations, such as per-document sharing, and implement it using a ReBAC service. Keep the existing RBAC system for coarse-grained permissions while routing fine-grained checks to the new service. Over time, you can migrate more logic as needed.

What is the "new enemy" problem and how do ReBAC systems handle it?

The "new enemy" problem is a race condition where a user is removed from a resource's access list, but a subsequent check is evaluated against a stale replica of the data, incorrectly granting access. Zanzibar-style ReBAC systems solve this by using consistency tokens, such as ZedTokens, which couple the resource data with the permission data, ensuring checks are never performed on outdated relationships.

Can RBAC be used for fine-grained permissions?

While technically possible, it is not practical. Achieving fine-grained control with RBAC requires creating a vast number of roles, often one per resource or user action, which leads to "role explosion." This undermines the administrative simplicity that is RBAC's primary benefit and creates a significant management burden.

Is operating a ReBAC system more complex than RBAC?

The complexity is different. With RBAC, the challenge is primarily administrative governance: managing role definitions, preventing role sprawl, and conducting regular access reviews. With ReBAC, the challenge is more technical and operational: deploying and scaling a distributed authorization service, managing schema evolution, and handling consistency guarantees across your applications.

How do you test and debug permissions in a ReBAC system?

ReBAC systems provide powerful introspection tools. An "Expand" API, for example, can return the full tree of relationships that resulted in a permission grant, making it easy to understand and debug complex access decisions. Many systems also offer online playgrounds and validation tools for designing and testing schemas before deployment.

Zanzibar for your applications?

See how AuthZed can add fine-grained permissions to your applications.