Course contentsShow
← Software Engineering
Lesson 1027 of 1,93331. Authentication and AuthorizationFree lesson

Role-Based Access Control (RBAC)

Understand RBAC: assigning permissions to roles, assigning roles to users, and managing role hierarchies.

Role-Based Access Control (RBAC)

You'll learn: How RBAC simplifies authorization by organizing permissions around roles rather than individual users.

What is RBAC?

Role-Based Access Control is an authorization model that assigns permissions to roles rather than directly to users. Users are then assigned one or more roles, inheriting all permissions associated with those roles. Think of it like a theater production: instead of telling each actor exactly what they can touch backstage, you define roles like "Stage Manager" or "Lead Actor," each with specific permissions, then assign people to those roles.

The Three-Layer Model

RBAC operates through three key relationships:

1. Permissions to Roles

Define what each role can do. For example:

  • Editor role → Can create, read, update documents
  • Admin role → Can create, read, update, delete documents AND manage users
  • Viewer role → Can only read documents

2. Roles to Users

Assign users to appropriate roles:

  • Alice → Admin
  • Bob → Editor
  • Carol → Viewer

3. Role Hierarchies

Roles can inherit from other roles, reducing duplication:

  • Admin inherits all permissions from Editor
  • Editor inherits all permissions from Viewer

Why RBAC Matters

Instead of managing permissions for thousands of individual users, you manage a handful of roles. When Bob changes departments, you simply change his role assignment rather than manually adjusting dozens of permission flags. When you need to update what editors can do, you modify the Editor role once, and all users with that role automatically inherit the change.

Key Takeaway: RBAC simplifies authorization management by grouping permissions into reusable roles, making it easier to maintain consistent access control as your system and team grow.