maeser.controllers.common.decorators module

maeser.controllers.common.decorators module#

This module contains decorators for rate limiting and admin access control in a Flask application.

© 2024 Carson Bush, Blaine Freestone

This file is part of Maeser.

Maeser is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Maeser is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with Maeser. If not, see <https://www.gnu.org/licenses/>.

maeser.controllers.common.decorators.admin_required(current_user)[source]#

Decorator to ensure that an endpoint can only be accessed by an admin.

Parameters:

current_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, current_user)[source]#

Decorator to rate limit an endpoint based on user’s remaining requests.

Parameters:
  • auth_manager – The authentication manager to handle request limits.

  • current_user – The user object containing request information.

Returns:

A wrapped endpoint function that checks for rate limits.