QA
Beginner LevelAuthentication & Authorization

What is Role-Based Access Control (RBAC) and how do Roles and Permissions map?

❓ Interview Prompt: Explain RBAC architecture, mapping users to roles and roles to permissions, and access evaluation.

Role-Based Access Control (RBAC) is an authorization model where access permissions are assigned to specific Roles, and Users are assigned one or more Roles.

Key Components:

•
Permissions: Fine-grained atomic actions (e.g. 'posts:create', 'users:delete', 'reports:view').
•
Roles: Logical groupings of permissions matching job functions (e.g. 'Admin', 'Editor', 'Viewer').
•
User-Role Mapping: Assigning roles to individual user accounts.

Advantages:

Decouples authorization logic from individual user IDs. Adding a new employee requires simply assigning a role rather than managing dozens of individual permissions.

Code Implementation Example

typescript
// Simple RBAC Permission Checker
const ROLE_PERMISSIONS: Record<string, string[]> = {
  admin: ['users:create', 'users:read', 'users:delete', 'posts:write'],
  editor: ['posts:write', 'posts:read'],
  viewer: ['posts:read']
};

function hasPermission(userRole: string, requiredPermission: string): boolean {
  const permissions = ROLE_PERMISSIONS[userRole] || [];
  return permissions.includes(requiredPermission);
}

console.log(hasPermission('editor', 'users:delete')); // false
console.log(hasPermission('admin', 'users:delete'));  // true
💡Simple RBAC permission verification mapping roles to atomic permissions.
🎯 Interview Key Takeaway

RBAC maps atomic permissions to roles, and roles to users, simplifying administrative authorization control.

#RBAC#Authorization#Permissions#Roles#Beginner
Back to all Authentication & Authorization Questions→

More Authentication & Authorization Interview Questions

Beginner LevelAuthentication & Authorization

Compare JWT Token Authentication versus Stateful Sessions, and explain OAuth 2.0 PKCE flow.

Beginner LevelAuthentication & Authorization

What is the fundamental difference between Authentication (AuthN) and Authorization (AuthZ)?

Beginner LevelAuthentication & Authorization

Why should passwords never be stored in plain text and how do bcrypt and Argon2id work?