Loading Depth Study
Preparing your workspace
RBAC assigns permissions to roles and then assigns users to those roles.
Role-based access control simplifies authorization when users naturally fall into groups such as student, mentor, admin, or owner. The application maps each role to a defined set of permissions. The server should enforce those permissions for every protected operation. RBAC is useful, but some systems also need resource ownership or organization-level rules when permissions depend on a particular record.
A learning platform might allow students to view their courses, mentors to manage assigned students, and admins to manage users and content.
const permissions = {
student: ['course.read'],
mentor: ['course.read', 'student.manage'],
admin: ['course.read', 'student.manage', 'user.manage']
};
function can(role, permission) {
return permissions[role]?.includes(permission) ?? false;
}The can function checks whether a role has the requested permission.