🚀 Objective
Implement Role-Based Authorization (RBAC) to introduce permission control between different user types (e.g., admin, user).
Currently, all authenticated users have equal permissions. This enhancement will improve security and moderation control.
🛠 Tasks
-
Add a role field in the User schema:
Type: String
Enum: ['user', 'admin']
Default: 'user'
-
Include role in the JWT access token payload.
-
Create an authorizeRoles middleware that: Accepts allowed roles as parameters
Restricts access if the user’s role is not permitted
-
Apply role restrictions:
Admin can delete/update any video or comment
Users can only modify/delete their own content
✅ Acceptance Criteria
-Role field is properly added and stored in the database
-JWT payload includes user role
-Middleware correctly restricts unauthorized access
-Unauthorized requests return HTTP 403
-Existing functionality remains unaffected
🧪 Testing Instructions
- Create one admin user and one regular user
- Verify:
- Admin can delete/update any content
- Regular user cannot modify other users’ content
🚀 Objective
Implement Role-Based Authorization (RBAC) to introduce permission control between different user types (e.g., admin, user).
Currently, all authenticated users have equal permissions. This enhancement will improve security and moderation control.
🛠 Tasks
Add a role field in the User schema:
Type: String
Enum: ['user', 'admin']
Default: 'user'
Include role in the JWT access token payload.
Create an authorizeRoles middleware that: Accepts allowed roles as parameters
Restricts access if the user’s role is not permitted
Apply role restrictions:
Admin can delete/update any video or comment
Users can only modify/delete their own content
✅ Acceptance Criteria
-Role field is properly added and stored in the database
-JWT payload includes user role
-Middleware correctly restricts unauthorized access
-Unauthorized requests return HTTP 403
-Existing functionality remains unaffected
🧪 Testing Instructions