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 710a873efbb Fix Admin team dropdown showing "no option" when creating 
Connections (#62368)
710a873efbb is described below

commit 710a873efbb90612bd7828e73e75c828c70070ff
Author: yuseok89 <[email protected]>
AuthorDate: Tue Feb 24 23:26:24 2026 +0900

    Fix Admin team dropdown showing "no option" when creating Connections 
(#62368)
---
 .../auth/managers/simple/simple_auth_manager.py    | 23 ++++++++++++++++++----
 .../managers/simple/test_simple_auth_manager.py    | 17 +++++++++-------
 .../api_fastapi/core_api/routes/ui/test_teams.py   |  8 ++++----
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git 
a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
 
b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
index d1e9126b9eb..1c546798616 100644
--- 
a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
+++ 
b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
@@ -265,7 +265,11 @@ class 
SimpleAuthManager(BaseAuthManager[SimpleAuthManagerUser]):
         user: SimpleAuthManagerUser,
         details: TeamDetails | None = None,
     ) -> bool:
-        return details.name in user.teams if details else False
+        if not details:
+            return False
+        if self._is_admin(user):
+            return True
+        return details.name in user.teams
 
     def is_authorized_variable(
         self,
@@ -356,6 +360,17 @@ class 
SimpleAuthManager(BaseAuthManager[SimpleAuthManagerUser]):
 
         return app
 
+    @staticmethod
+    def _is_admin(user: SimpleAuthManagerUser) -> bool:
+        """Return whether the user has the Admin role."""
+        if not user.role:
+            return False
+
+        role_str = user.role.upper()
+        role = SimpleAuthManagerRole[role_str]
+
+        return role == SimpleAuthManagerRole.ADMIN
+
     @staticmethod
     def _is_authorized(
         *,
@@ -379,9 +394,7 @@ class 
SimpleAuthManager(BaseAuthManager[SimpleAuthManagerUser]):
         if not user.role:
             return False
 
-        role_str = user.role.upper()
-        role = SimpleAuthManagerRole[role_str]
-        if role == SimpleAuthManagerRole.ADMIN:
+        if SimpleAuthManager._is_admin(user):
             return True
 
         if team_name and team_name not in user.teams:
@@ -390,6 +403,8 @@ class 
SimpleAuthManager(BaseAuthManager[SimpleAuthManagerUser]):
         if not allow_get_role:
             allow_get_role = allow_role
 
+        role_str = user.role.upper()
+        role = SimpleAuthManagerRole[role_str]
         if method == "GET":
             return role.order >= allow_get_role.order
         return role.order >= allow_role.order
diff --git 
a/airflow-core/tests/unit/api_fastapi/auth/managers/simple/test_simple_auth_manager.py
 
b/airflow-core/tests/unit/api_fastapi/auth/managers/simple/test_simple_auth_manager.py
index 4de8b0ba024..3ce33c3efc4 100644
--- 
a/airflow-core/tests/unit/api_fastapi/auth/managers/simple/test_simple_auth_manager.py
+++ 
b/airflow-core/tests/unit/api_fastapi/auth/managers/simple/test_simple_auth_manager.py
@@ -307,18 +307,21 @@ class TestSimpleAuthManager:
         )
 
     @pytest.mark.parametrize(
-        ("user_teams", "team", "expected"),
+        ("user_teams", "team", "role", "expected"),
         [
-            (None, None, False),
-            (["test"], "marketing", False),
-            (["test"], "test", True),
-            (["test", "marketing"], "test", True),
+            (None, None, None, False),
+            (["test"], "marketing", None, False),
+            (["test"], "test", None, True),
+            (["test", "marketing"], "test", None, True),
+            # Admin role can access all teams regardless of user.teams
+            ([], "team_a", "ADMIN", True),
+            (None, "team_b", "ADMIN", True),
         ],
     )
-    def test_is_authorized_team(self, auth_manager, user_teams, team, 
expected):
+    def test_is_authorized_team(self, auth_manager, user_teams, team, role, 
expected):
         result = auth_manager.is_authorized_team(
             method="GET",
-            user=SimpleAuthManagerUser(username="test", role=None, 
teams=user_teams),
+            user=SimpleAuthManagerUser(username="test", role=role, 
teams=user_teams),
             details=TeamDetails(name=team),
         )
         assert expected is result
diff --git 
a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_teams.py 
b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_teams.py
index b8c54b35ddc..d524f754865 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_teams.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_teams.py
@@ -52,11 +52,11 @@ class TestListTeams:
         assert response.status_code == 200
         assert response.json() == {
             "teams": [
-                {
-                    "name": "team1",
-                },
+                {"name": "team1"},
+                {"name": "team2"},
+                {"name": "team3"},
             ],
-            "total_entries": 1,
+            "total_entries": 3,
         }
 
     @conf_vars({("core", "multi_team"): "true"})

Reply via email to