Skip to content

Commit

Permalink
Removed deprecated method requires_access from module airflow.api_con…
Browse files Browse the repository at this point in the history
…nexion.security (apache#41910)

* Removed deprecated method requires_access from module airflow.api_connexion.security

* news fragment added
  • Loading branch information
dirrao authored Aug 31, 2024
1 parent fe15f59 commit 3b76ec9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
25 changes: 1 addition & 24 deletions airflow/api_connexion/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
# under the License.
from __future__ import annotations

import warnings
from functools import wraps
from typing import TYPE_CHECKING, Callable, Sequence, TypeVar, cast
from typing import TYPE_CHECKING, Callable, TypeVar, cast

from flask import Response, g

Expand All @@ -33,7 +32,6 @@
PoolDetails,
VariableDetails,
)
from airflow.exceptions import RemovedInAirflow3Warning
from airflow.utils.airflow_flask_app import get_airflow_app
from airflow.www.extensions.init_auth_manager import get_auth_manager

Expand All @@ -60,27 +58,6 @@ def check_authentication() -> None:
raise Unauthenticated(headers=response.headers)


def requires_access(permissions: Sequence[tuple[str, str]] | None = None) -> Callable[[T], T]:
"""
Check current user's permissions against required permissions.
Deprecated. Do not use this decorator, use one of the decorator `has_access_*` defined in
airflow/api_connexion/security.py instead.
This decorator will only work with FAB authentication and not with other auth providers.
This decorator might be used in user plugins, do not remove it.
"""
warnings.warn(
"The 'requires_access' decorator is deprecated. Please use one of the decorator `requires_access_*`"
"defined in airflow/api_connexion/security.py instead.",
RemovedInAirflow3Warning,
stacklevel=2,
)
from airflow.providers.fab.auth_manager.decorators.auth import _requires_access_fab

return _requires_access_fab(permissions)


def _requires_access(*, is_authorized_callback: Callable[[], bool], func: Callable, args, kwargs) -> bool:
"""
Define the behavior whether the user is authorized to access the resource.
Expand Down
1 change: 1 addition & 0 deletions newsfragments/41910.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed deprecated method ``requires_access`` from module ``airflow.api_connexion.security``. Please use ``requires_access_*`` instead.

0 comments on commit 3b76ec9

Please sign in to comment.