NODEJS Contents

Role-Based Access Control

RBAC assigns permissions to roles, then roles to users. It scales well for organizational policies when designed with clear role boundaries and auditability.

On this page

What RBAC Solves

Role-Based Access Control (RBAC) is a way to manage authorization at scale. Instead of assigning permissions to each user, you define roles (admin, editor, viewer) and assign permissions to those roles.

RBAC Model

  • User → has roles
  • Role → grants permissions
  • Permission → allows an action on a resource

Example Roles

Role: admin
  - user:read
  - user:write
  - billing:manage

Role: support
  - user:read
  - ticket:write

Role: viewer
  - dashboard:read

Production Design Principles

  • Keep roles coarse (few roles, clear meaning)
  • Use permissions for fine-grained controls
  • Audit role changes (who changed what, when)
  • Avoid role explosion (roles per user is a smell)

Implementation Notes

Load authorization data efficiently: either embed roles in access tokens (short TTL) or fetch from a cache/store. Ensure changes propagate within an acceptable time window.