This is an automated email from the ASF dual-hosted git repository. vincbeck pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new 4d96a9a3a1 Remove dependency of `Connexion` from auth manager interface (#36209) 4d96a9a3a1 is described below commit 4d96a9a3a1bcf099856051e51bc328afbf558da6 Author: Vincent <97131062+vincb...@users.noreply.github.com> AuthorDate: Wed Dec 13 13:32:21 2023 -0500 Remove dependency of `Connexion` from auth manager interface (#36209) --- airflow/auth/managers/base_auth_manager.py | 4 ++-- airflow/providers/fab/auth_manager/fab_auth_manager.py | 6 +++--- airflow/www/extensions/init_views.py | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/airflow/auth/managers/base_auth_manager.py b/airflow/auth/managers/base_auth_manager.py index fb57c984d5..466e728774 100644 --- a/airflow/auth/managers/base_auth_manager.py +++ b/airflow/auth/managers/base_auth_manager.py @@ -32,7 +32,7 @@ from airflow.utils.log.logging_mixin import LoggingMixin from airflow.utils.session import NEW_SESSION, provide_session if TYPE_CHECKING: - from connexion import FlaskApi + from flask import Blueprint from sqlalchemy.orm import Session from airflow.auth.managers.models.base_user import BaseUser @@ -79,7 +79,7 @@ class BaseAuthManager(LoggingMixin): """ return [] - def get_api_endpoints(self) -> None | FlaskApi: + def get_api_endpoints(self) -> None | Blueprint: """Return API endpoint(s) definition for the auth manager.""" return None diff --git a/airflow/providers/fab/auth_manager/fab_auth_manager.py b/airflow/providers/fab/auth_manager/fab_auth_manager.py index 3f160da497..201dc050f9 100644 --- a/airflow/providers/fab/auth_manager/fab_auth_manager.py +++ b/airflow/providers/fab/auth_manager/fab_auth_manager.py @@ -23,7 +23,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Container from connexion import FlaskApi -from flask import url_for +from flask import Blueprint, url_for from sqlalchemy import select from sqlalchemy.orm import Session, joinedload @@ -147,7 +147,7 @@ class FabAuthManager(BaseAuthManager): SYNC_PERM_COMMAND, # not in a command group ] - def get_api_endpoints(self) -> None | FlaskApi: + def get_api_endpoints(self) -> None | Blueprint: folder = Path(__file__).parents[0].resolve() # this is airflow/auth/managers/fab/ with folder.joinpath("openapi", "v1.yaml").open() as f: specification = safe_load(f) @@ -161,7 +161,7 @@ class FabAuthManager(BaseAuthManager): strict_validation=True, validate_responses=True, validator_map={"body": _CustomErrorRequestBodyValidator}, - ) + ).blueprint def get_user_display_name(self) -> str: """Return the user's display name associated to the user in session.""" diff --git a/airflow/www/extensions/init_views.py b/airflow/www/extensions/init_views.py index e057615f9d..92f2145764 100644 --- a/airflow/www/extensions/init_views.py +++ b/airflow/www/extensions/init_views.py @@ -329,9 +329,8 @@ def init_api_experimental(app): def init_api_auth_provider(app): """Initialize the API offered by the auth manager.""" auth_mgr = get_auth_manager() - api = auth_mgr.get_api_endpoints() - if api: - blueprint = api.blueprint + blueprint = auth_mgr.get_api_endpoints() + if blueprint: base_paths.append(blueprint.url_prefix) app.register_blueprint(blueprint) app.extensions["csrf"].exempt(blueprint)