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 certain actions.
Click to reveal answer
intermediate
How do you define roles in a Flask app using Flask-Login and Flask-Principal?
You create roles as strings or database entries and assign them to users. Flask-Principal helps check these roles to allow or deny access.
Click to reveal answer
beginner
What is the purpose of the @login_required decorator in Flask?
It ensures that only logged-in users can access a route. It is often combined with role checks for RBAC.
Click to reveal answer
intermediate
How can you restrict a Flask route to only users with the 'admin' role?
You check the user's roles inside the route or use Flask-Principal's @roles_required('admin') decorator to allow access only to admins.
Click to reveal answer
beginner
Why is RBAC better than giving permissions directly to users?
RBAC makes managing permissions easier by grouping them into roles. When a user's role changes, their permissions update automatically.
Click to reveal answer
In Flask RBAC, what does a 'role' represent?
✗ Incorrect
A role groups permissions that define what actions a user can perform.
Which Flask extension helps manage user sessions and login status?
✗ Incorrect
Flask-Login manages user sessions and login states.
What decorator would you use to require a user to be logged in before accessing a route?
✗ Incorrect
@login_required ensures only logged-in users can access the route.
How do you check if a user has the 'admin' role in Flask?
✗ Incorrect
User roles are usually stored in a list or set; checking membership confirms role.
Why is it better to assign roles instead of individual permissions to users?
✗ Incorrect
Roles group permissions, making it easier to manage user access.
Explain how Role-based Access Control works in a Flask application.
Think about how you decide who can enter certain rooms in a building.
You got /4 concepts.
Describe how you would implement a route that only 'admin' users can access in Flask.
Consider using decorators and role membership checks.
You got /4 concepts.