Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix security manager inheritance in fab provider #36538

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions airflow/providers/fab/auth_manager/fab_auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# under the License.
from __future__ import annotations

import warnings
from functools import cached_property
from pathlib import Path
from typing import TYPE_CHECKING, Container
Expand All @@ -43,7 +42,7 @@
GroupCommand,
)
from airflow.configuration import conf
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.models import DagModel
from airflow.providers.fab.auth_manager.cli_commands.definition import (
ROLES_COMMANDS,
Expand Down Expand Up @@ -334,20 +333,12 @@ def security_manager(self) -> FabAirflowSecurityManagerOverride:
from airflow.providers.fab.auth_manager.security_manager.override import (
FabAirflowSecurityManagerOverride,
)
from airflow.www.security_manager import AirflowSecurityManagerV2

sm_from_config = self.appbuilder.get_app.config.get("SECURITY_MANAGER_CLASS")
if sm_from_config:
if not issubclass(sm_from_config, AirflowSecurityManagerV2):
raise Exception(
"""Your CUSTOM_SECURITY_MANAGER must extend AirflowSecurityManagerV2,
not FAB's own security manager."""
)
if not issubclass(sm_from_config, FabAirflowSecurityManagerOverride):
warnings.warn(
"Please make your custom security manager inherit from "
"FabAirflowSecurityManagerOverride instead of AirflowSecurityManager.",
AirflowProviderDeprecationWarning,
raise Exception(
"""Your CUSTOM_SECURITY_MANAGER must extend FabAirflowSecurityManagerOverride."""
)
return sm_from_config(self.appbuilder)

Expand Down
Loading