diff --git a/.github/workflows/basic-tests.yml b/.github/workflows/basic-tests.yml index 8acb271d8f191..f5b1d54084b86 100644 --- a/.github/workflows/basic-tests.yml +++ b/.github/workflows/basic-tests.yml @@ -169,7 +169,8 @@ jobs: nohup airflow webserver --port 8080 & echo "Started webserver" env: - AIRFLOW__API__AUTH_BACKENDS: airflow.api.auth.backend.session,airflow.api.auth.backend.basic_auth + AIRFLOW__API__AUTH_BACKENDS: >- + airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth AIRFLOW__WEBSERVER__EXPOSE_CONFIG: "True" AIRFLOW__CORE__LOAD_EXAMPLES: "True" AIRFLOW_HOME: "${{ github.workspace }}/airflow_home" diff --git a/airflow/api/auth/backend/basic_auth.py b/airflow/api/auth/backend/basic_auth.py deleted file mode 100644 index 382b9a95982cc..0000000000000 --- a/airflow/api/auth/backend/basic_auth.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -""" -This module is deprecated. - -Please use :mod:`airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. -""" - -from __future__ import annotations - -import warnings -from typing import TYPE_CHECKING, Any, Callable - -import airflow.providers.fab.auth_manager.api.auth.backend.basic_auth as fab_basic_auth -from airflow.exceptions import RemovedInAirflow3Warning - -if TYPE_CHECKING: - from airflow.providers.fab.auth_manager.models import User - -CLIENT_AUTH: tuple[str, str] | Any | None = None - -warnings.warn( - "This module is deprecated. Please use `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead.", - RemovedInAirflow3Warning, - stacklevel=2, -) - - -def init_app(_): - fab_basic_auth.init_app(_) - - -def auth_current_user() -> User | None: - return fab_basic_auth.auth_current_user() - - -def requires_authentication(function: Callable): - return fab_basic_auth.requires_authentication(function) diff --git a/airflow/api_connexion/openapi/v1.yaml b/airflow/api_connexion/openapi/v1.yaml index a0809f045db89..a92499fc81e49 100644 --- a/airflow/api_connexion/openapi/v1.yaml +++ b/airflow/api_connexion/openapi/v1.yaml @@ -176,7 +176,7 @@ info: `airflow config get-value api auth_backends` command as in the example below. ```bash $ airflow config get-value api auth_backends - airflow.api.auth.backend.basic_auth + airflow.providers.fab.auth_manager.api.auth.backend.basic_auth ``` The default is to deny all requests. diff --git a/airflow/auth/managers/fab/api/auth/backend/basic_auth.py b/airflow/auth/managers/fab/api/auth/backend/basic_auth.py deleted file mode 100644 index 382b9a95982cc..0000000000000 --- a/airflow/auth/managers/fab/api/auth/backend/basic_auth.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -""" -This module is deprecated. - -Please use :mod:`airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. -""" - -from __future__ import annotations - -import warnings -from typing import TYPE_CHECKING, Any, Callable - -import airflow.providers.fab.auth_manager.api.auth.backend.basic_auth as fab_basic_auth -from airflow.exceptions import RemovedInAirflow3Warning - -if TYPE_CHECKING: - from airflow.providers.fab.auth_manager.models import User - -CLIENT_AUTH: tuple[str, str] | Any | None = None - -warnings.warn( - "This module is deprecated. Please use `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead.", - RemovedInAirflow3Warning, - stacklevel=2, -) - - -def init_app(_): - fab_basic_auth.init_app(_) - - -def auth_current_user() -> User | None: - return fab_basic_auth.auth_current_user() - - -def requires_authentication(function: Callable): - return fab_basic_auth.requires_authentication(function) diff --git a/clients/python/README.md b/clients/python/README.md index f0964d555276f..055aa4d24d885 100644 --- a/clients/python/README.md +++ b/clients/python/README.md @@ -182,7 +182,7 @@ If you want to check which auth backend is currently set, you can use ```bash $ airflow config get-value api auth_backends -airflow.api.auth.backend.basic_auth +airflow.providers.fab.auth_manager.api.auth.backend.basic_auth ``` The default is to deny all requests. @@ -534,11 +534,11 @@ that uses the API to run the tests. To do that, you need to: ```ini [api] -auth_backend = airflow.api.auth.backend.session,airflow.api.auth.backend.basic_auth +auth_backend = airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth ``` You can also set it by env variable: -`export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.api.auth.backend.basic_auth` +`export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` * configure your airflow webserver to load example dags In the `[core]` section of your `airflow.cfg` set: diff --git a/clients/python/test_python_client.py b/clients/python/test_python_client.py index d36f6d1bcc03c..d4d3f98efd834 100644 --- a/clients/python/test_python_client.py +++ b/clients/python/test_python_client.py @@ -49,7 +49,7 @@ # configured also with the basic_auth as backend additionally to regular session backend needed # by the UI. In the `[api]` section of your `airflow.cfg` set: # -# auth_backend = airflow.api.auth.backend.session,airflow.api.auth.backend.basic_auth +# auth_backend = airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth # # Make sure that your user/name are configured properly - using the user/password that has admin # privileges in Airflow diff --git a/dev/README_RELEASE_PYTHON_CLIENT.md b/dev/README_RELEASE_PYTHON_CLIENT.md index c631dddb3f56f..ea63636bb1444 100644 --- a/dev/README_RELEASE_PYTHON_CLIENT.md +++ b/dev/README_RELEASE_PYTHON_CLIENT.md @@ -464,7 +464,7 @@ and allows you to test the client in a real environment. variable in `files/airflow-breeze-config/init.sh`: ```shell -export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.api.auth.backend.basic_auth +export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True ``` diff --git a/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py b/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py index c7ecfcf305308..d5b054646d978 100644 --- a/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py +++ b/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py @@ -1024,7 +1024,7 @@ def _deploy_helm_chart( "-v", "1", "--set", - "config.api.auth_backends=airflow.api.auth.backend.basic_auth", + "config.api.auth_backends=airflow.providers.fab.auth_manager.api.auth.backend.basic_auth", "--set", "config.logging.logging_level=DEBUG", "--set", diff --git a/docs/apache-airflow-providers-fab/auth-manager/api-authentication.rst b/docs/apache-airflow-providers-fab/auth-manager/api-authentication.rst index cd657b1395f15..0c70cb06bf911 100644 --- a/docs/apache-airflow-providers-fab/auth-manager/api-authentication.rst +++ b/docs/apache-airflow-providers-fab/auth-manager/api-authentication.rst @@ -43,7 +43,7 @@ command as in the example below. .. code-block:: console $ airflow config get-value api auth_backends - airflow.api.auth.backend.basic_auth + airflow.providers.fab.auth_manager.api.auth.backend.basic_auth Kerberos authentication ''''''''''''''''''''''' @@ -78,7 +78,7 @@ To enable basic authentication, set the following in the configuration: .. code-block:: ini [api] - auth_backends = airflow.api.auth.backend.basic_auth + auth_backends = airflow.providers.fab.auth_manager.api.auth.backend.basic_auth Username and password needs to be base64 encoded and send through the ``Authorization`` HTTP header in the following format: diff --git a/docs/apache-airflow/howto/docker-compose/docker-compose.yaml b/docs/apache-airflow/howto/docker-compose/docker-compose.yaml index 92b0eab93713b..eb3656940e721 100644 --- a/docs/apache-airflow/howto/docker-compose/docker-compose.yaml +++ b/docs/apache-airflow/howto/docker-compose/docker-compose.yaml @@ -60,7 +60,8 @@ x-airflow-common: AIRFLOW__CORE__FERNET_KEY: '' AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true' AIRFLOW__CORE__LOAD_EXAMPLES: 'true' - AIRFLOW__API__AUTH_BACKENDS: 'airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session' + AIRFLOW__API__AUTH_BACKENDS: >- + airflow.providers.fab.auth_manager.api.auth.backend.basic_auth,airflow.api.auth.backend.session # yamllint disable rule:line-length # Use simple http server on scheduler for health checks # See https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/check-health.html#scheduler-health-check-server diff --git a/newsfragments/41663.significant.rst b/newsfragments/41663.significant.rst new file mode 100644 index 0000000000000..169d7fb5c6732 --- /dev/null +++ b/newsfragments/41663.significant.rst @@ -0,0 +1 @@ +Removed deprecated auth ``airflow.api.auth.backend.basic_auth`` from ``auth_backends``. Please use ``airflow.providers.fab.auth_manager.api.auth.backend.basic_auth`` instead. diff --git a/tests/core/test_configuration.py b/tests/core/test_configuration.py index 94f5bc4c260f7..d02e9b4b3cb82 100644 --- a/tests/core/test_configuration.py +++ b/tests/core/test_configuration.py @@ -646,13 +646,15 @@ def test_auth_backends_adds_session(self): ), }, } - test_conf.read_dict({"api": {"auth_backends": "airflow.api.auth.backend.basic_auth"}}) + test_conf.read_dict( + {"api": {"auth_backends": "airflow.providers.fab.auth_manager.api.auth.backend.basic_auth"}} + ) with pytest.warns(FutureWarning): test_conf.validate() assert ( test_conf.get("api", "auth_backends") - == "airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session" + == "airflow.providers.fab.auth_manager.api.auth.backend.basic_auth,airflow.api.auth.backend.session" ) def test_command_from_env(self): @@ -1028,11 +1030,11 @@ def test_deprecated_values_from_conf(self): "old, new", [ ( - ("api", "auth_backend", "airflow.api.auth.backend.basic_auth"), + ("api", "auth_backend", "airflow.providers.fab.auth_manager.api.auth.backend.basic_auth"), ( "api", "auth_backends", - "airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session", + "airflow.providers.fab.auth_manager.api.auth.backend.basic_auth,airflow.api.auth.backend.session", ), ), ( diff --git a/tests/providers/fab/auth_manager/api/auth/backend/test_basic_auth.py b/tests/providers/fab/auth_manager/api/auth/backend/test_basic_auth.py index 1f64b3181576d..4a5104829a065 100644 --- a/tests/providers/fab/auth_manager/api/auth/backend/test_basic_auth.py +++ b/tests/providers/fab/auth_manager/api/auth/backend/test_basic_auth.py @@ -22,7 +22,7 @@ from flask import Response from flask_appbuilder.const import AUTH_LDAP -from airflow.api.auth.backend.basic_auth import requires_authentication +from airflow.providers.fab.auth_manager.api.auth.backend.basic_auth import requires_authentication from airflow.www import app as application from tests.test_utils.compat import AIRFLOW_V_2_9_PLUS