This is an automated email from the ASF dual-hosted git repository.

potiuk 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 c2a9833ba7 feat: deprecated basic auth 
airflow.api.auth.backend.basic_auth removed (#41663)
c2a9833ba7 is described below

commit c2a9833ba74ec273e4a668c7a7962c12171a6299
Author: Gopal Dirisala <[email protected]>
AuthorDate: Thu Aug 22 19:59:22 2024 +0530

    feat: deprecated basic auth airflow.api.auth.backend.basic_auth removed 
(#41663)
    
    * deprecatd basic auth airflow.api.auth.backend.basic_auth removed
    
    * news fragment added
    
    * deprecatd basic auth airflow.api.auth.backend.basic_auth removed
---
 .github/workflows/basic-tests.yml                  |  3 +-
 airflow/api/auth/backend/basic_auth.py             | 52 ----------------------
 airflow/api_connexion/openapi/v1.yaml              |  2 +-
 .../managers/fab/api/auth/backend/basic_auth.py    | 52 ----------------------
 clients/python/README.md                           |  6 +--
 clients/python/test_python_client.py               |  2 +-
 dev/README_RELEASE_PYTHON_CLIENT.md                |  2 +-
 .../airflow_breeze/commands/kubernetes_commands.py |  2 +-
 .../auth-manager/api-authentication.rst            |  4 +-
 .../howto/docker-compose/docker-compose.yaml       |  3 +-
 newsfragments/41663.significant.rst                |  1 +
 tests/core/test_configuration.py                   | 10 +++--
 .../api/auth/backend/test_basic_auth.py            |  2 +-
 13 files changed, 21 insertions(+), 120 deletions(-)

diff --git a/.github/workflows/basic-tests.yml 
b/.github/workflows/basic-tests.yml
index 8acb271d8f..f5b1d54084 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 382b9a9598..0000000000
--- 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 a0809f045d..a92499fc81 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 382b9a9598..0000000000
--- 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 f0964d5552..055aa4d24d 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 d36f6d1bcc..d4d3f98efd 100644
--- a/clients/python/test_python_client.py
+++ b/clients/python/test_python_client.py
@@ -49,7 +49,7 @@ from airflow_client.client.model.dag_run import DAGRun
 # 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 c631dddb3f..ea63636bb1 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 c7ecfcf305..d5b054646d 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 cd657b1395..0c70cb06bf 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 92b0eab937..eb3656940e 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 0000000000..169d7fb5c6
--- /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 94f5bc4c26..d02e9b4b3c 100644
--- a/tests/core/test_configuration.py
+++ b/tests/core/test_configuration.py
@@ -646,13 +646,15 @@ AIRFLOW_HOME = /root/airflow
                     ),
                 },
             }
-            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 @@ sql_alchemy_conn=sqlite://test
         "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 1f64b31815..4a5104829a 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 @@ import pytest
 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
 

Reply via email to