maeser.controllers.common.decorators module#
This module contains decorators for rate limiting and admin access control in a Flask application.
- maeser.controllers.common.decorators.admin_required(current_user: User)[source]#
Decorator to ensure that an endpoint can only be accessed by an admin.
Aborts endpoint with code 403 if user does not have admin access.
- Parameters:
current_user (User) – The user object to check for admin privileges.
- Returns:
A wrapped endpoint function that checks for admin access.
- maeser.controllers.common.decorators.rate_limited(auth_manager: UserManager, current_user: User)[source]#
Decorator to rate limit an endpoint based on user’s remaining requests.
Aborts endpoint with code 429 if the user is out of requests.
- Parameters:
auth_manager (UserManager) – The authentication manager to handle request limits.
current_user (User) – The user object containing request information.
- Returns:
A wrapped endpoint function that checks for rate limits.