maeser.controllers.login_api module#
Module for handling login and GitHub OAuth2 authorization controllers.
© 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.login_api.controller()[source]#
Raises NotImplementedError for unimplemented controllers.
This function should be replaced with a specific login controller implementation, such as ‘login_controller’, ‘github_authorize_controller’, or ‘github_auth_callback_controller’.
- maeser.controllers.login_api.github_auth_callback_controller(current_user, auth_manager, app_name: str | None = None, main_logo_light: str | None = None, main_logo_dark: str | None = None, favicon: str | None = None, login_redirect: str = 'maeser.login')[source]#
- maeser.controllers.login_api.github_authorize_controller(current_user, github_authenticator)[source]#
Handles GitHub OAuth2 authorization.
- Parameters:
current_user (User) – The currently logged-in user.
github_authenticator (GitHubAuthenticator) – The GitHub authenticator to get OAuth2 info.
- Returns:
The response object to redirect to the OAuth2 provider.
- Return type:
Response
- maeser.controllers.login_api.is_safe_url(target)[source]#
Checks if a URL is safe for redirection.
- Parameters:
target (str) – The target URL to check.
- Returns:
True if the URL is safe, False otherwise.
- Return type:
bool
- maeser.controllers.login_api.login_controller(auth_manager, app_name: str | None = None, main_logo_light: str | None = None, main_logo_dark: str | None = None, favicon: str | None = None)[source]#
Handles user login.
- Parameters:
auth_manager (AuthManager) – The authentication manager to handle user authentication.
- Returns:
The response object to render the login page or redirect.
- Return type:
Response