Recall & Review
beginner
What is Role-based Access Control (RBAC)?
RBAC is a way to control who can do what in an app by assigning roles to users. Each role has permissions that allow or block actions.
Click to reveal answer
beginner
How do you check a user's role in Express middleware?
You create middleware that looks at the user's role stored in the request (like req.user.role) and decides if they can continue or get blocked.
Click to reveal answer
intermediate
Why use middleware for RBAC in Express?
Middleware lets you check permissions before your route runs. This keeps your code clean and secure by stopping unauthorized users early.
Click to reveal answer
beginner
What happens if a user tries to access a route without the right role?
The middleware sends a response like 403 Forbidden, telling the user they don’t have permission to access that resource.
Click to reveal answer
intermediate
How can roles be stored and accessed in an Express app?
Roles can be stored in the user’s session, JWT token, or database. When a request comes in, middleware reads the role from these places to check permissions.
Click to reveal answer
In Express, where is the best place to check user roles for access control?
✗ Incorrect
Middleware runs before route handlers and is the best place to check roles and permissions to block unauthorized access early.
What HTTP status code should you send when a user is not allowed to access a resource due to role restrictions?
✗ Incorrect
403 Forbidden means the user is authenticated but does not have permission to access the resource.
Which of these is NOT a common way to store user roles in an Express app?
✗ Incorrect
Local storage on the client is not secure for storing roles because it can be modified by the user.
What is the main benefit of using RBAC in your Express app?
✗ Incorrect
RBAC helps control what users can do by assigning roles with specific permissions.
If a user has the role 'admin', what should your RBAC middleware do?
✗ Incorrect
Admins usually have permission to access special routes, so middleware should allow them.
Explain how you would implement role-based access control in an Express app using middleware.
Think about how middleware can stop or allow requests based on user roles.
You got /4 concepts.
Describe why role-based access control is important for web applications.
Consider what happens if everyone could do everything in an app.
You got /4 concepts.