Hierarchical RBAC in Node.js — without deploying OpenFGA

Implement hierarchical RBAC in Node.js without external services. Automatically inherit roles with nested-rbac. Easy, fast, and without additional infrastructure.

sábado, 4 de julio de 2026 • 3 min read • Q2BSTUDIO Team

Role inheritance without OpenFGA or external services

In SaaS application development, one of the most recurring challenges is managing permissions over hierarchically organized resources. The typical structure — organization, team, project, task — requires that roles assigned at a higher level are automatically inherited downwards. However, most traditional RBAC (role-based access control) libraries model flat roles, forcing the developer to manually traverse the ancestor chain on each path, risking forgetting a level and blocking legitimate access for admin users.

There are two extreme approaches: on one hand, flat libraries like CASL or Casbin, excellent for defining roles but without support for inheritance between parent and child resources. On the other hand, FGA engines in the style of Zanzibar (OpenFGA, SpiceDB) solve the problem at Google scale, but require an external service with its own relationship graph, policy DSL, and considerable operational overhead. For 90% of applications, this infrastructure is excessive.

Here a middle ground emerges: implementing role inheritance directly in the application code, without relying on external services. With a lightweight, dependency-free library like nested-rbac, you define a hierarchy of resource types and a role map with permissions. When evaluating an action on a resource, the engine collects all assignments from the target resource and its ancestors (project, team, organization), applies grant and deny rules (with support for wildcards and domains), and returns the result. The logic is transparent: the organization admin can delete tasks at any level without additional assignments.

To integrate this pattern into a real application, the developer only needs to provide a function that resolves the ancestor chain from their database — the engine remains agnostic — and then use it in middleware like Express. This avoids nested if statements and centralizes authorization. This approach is ideal for projects requiring custom applications with complex access models, where operational scalability does not justify a dedicated FGA engine.

At Q2BSTUDIO, as a custom software development company, we apply these architectures to ensure permissions are correctly inherited from the organization down to the most granular resource level. Additionally, we combine this logic with aws and azure cloud services to deploy robust and scalable systems. Proper implementation of hierarchical RBAC is also a cornerstone of cybersecurity, as it prevents unauthorized users from accessing sensitive information by skipping levels in the hierarchy.

With the growing adoption of artificial intelligence and AI agents that act on business data, the need for fine-grained and inherited access control becomes even more critical. These agents must respect the same permissions as human users, and a library like nested-rbac allows modeling that inheritance without added complexity. Likewise, in the field of business intelligence services like power bi, reports and dashboards often depend on hierarchical data; inheriting permissions from the organization down to the report avoids having to assign roles one by one on each visualization.

In summary, managing hierarchical authorizations is a fundamental aspect that every development team must address carefully. Opting for a lightweight, code-integrated solution — instead of deploying an external engine — reduces operational costs and maintains flexibility. At Q2BSTUDIO, we help companies design and implement these systems, ensuring each user has exactly the access they need, no more and no less, and that inheritance works naturally across the entire resource hierarchy. If you are building a SaaS platform or a corporate application, consider adopting hierarchical RBAC from the start; your development team and your users will thank you.

To learn more about applying these patterns in your project, visit our section on aws and azure cloud services, where we deploy scalable and secure solutions.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.