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

vatsrahul1001 pushed a commit to branch backport-5040171-v3-4-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 3b46c9579705c94d3af79e0832dcb23daafe998c
Author: Jed Cunningham <[email protected]>
AuthorDate: Mon Nov 30 16:34:48 2026 +0530

    [v3-4-test] Ship the Dag bundle permission in Airflow 3.4.1 (#76474)
    
    (cherry picked from commit 94018444cdf0663337849d6fe5986d257f0a7403)
    
    Co-authored-by: Jed Cunningham 
<[email protected]>
    Co-Authored-By: Claude <[email protected]>
---
 airflow-core/newsfragments/76474.significant.rst            | 13 +++++++++++++
 providers/fab/docs/changelog.rst                            |  4 ++--
 .../airflow/providers/fab/auth_manager/fab_auth_manager.py  |  9 +++++----
 .../tests/unit/fab/auth_manager/test_fab_auth_manager.py    |  7 ++++---
 providers/keycloak/docs/auth-manager/manage/permissions.rst |  2 +-
 providers/keycloak/docs/changelog.rst                       |  4 ++--
 .../airflow/providers/keycloak/auth_manager/cli/commands.py |  5 +++++
 .../tests/unit/keycloak/auth_manager/cli/test_commands.py   |  9 +++++++--
 8 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/airflow-core/newsfragments/76474.significant.rst 
b/airflow-core/newsfragments/76474.significant.rst
new file mode 100644
index 00000000000..566410cc92f
--- /dev/null
+++ b/airflow-core/newsfragments/76474.significant.rst
@@ -0,0 +1,13 @@
+Dag bundles have their own read permission
+
+The Dag Bundles page and ``GET /api/v2/dagBundles`` used to show a bundle to 
anyone who could read a
+Dag in it. They now need the new Dag bundles permission, because they show 
every file and count in
+a bundle. Users who can read Dags but lack it get a 403. By default it is held 
by:
+
+* Simple auth manager: ``op`` and ``admin``.
+* FAB auth manager: ``Op`` and ``Admin``. Upgrade 
``apache-airflow-providers-fab`` together with
+  Airflow, since older releases deny the page to every role. Custom roles need 
``can read`` and
+  ``menu access`` on ``Dag Bundles``.
+* Keycloak auth manager: every role. In multi-team mode, ``SuperAdmin`` only. 
Multi-team
+  deployments must upgrade ``apache-airflow-providers-keycloak`` together with 
Airflow, since older
+  releases let every team role read it.
diff --git a/providers/fab/docs/changelog.rst b/providers/fab/docs/changelog.rst
index 31e9cd1964e..1ed99594e2e 100644
--- a/providers/fab/docs/changelog.rst
+++ b/providers/fab/docs/changelog.rst
@@ -21,8 +21,8 @@ Changelog
 ---------
 
 .. note::
-    Airflow 3.4.0 gives Dag bundles their own ``Dag Bundles`` resource, which 
``Op`` and ``Admin``
-    get by default. Upgrade this provider together with Airflow 3.4.0: older 
releases deny the Dag
+    Airflow 3.4.1 gives Dag bundles their own ``Dag Bundles`` resource, which 
``Op`` and ``Admin``
+    get by default. Upgrade this provider together with Airflow 3.4.1: older 
releases deny the Dag
     bundle pages and API to every role, including ``Admin``, while still 
showing the Browse menu
     entry. Custom roles need ``can read`` and ``menu access`` on ``Dag 
Bundles`` added by hand.
 
diff --git 
a/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py 
b/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py
index 2806cdf5e96..3555920860d 100644
--- a/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py
+++ b/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py
@@ -193,14 +193,15 @@ if AIRFLOW_V_3_1_PLUS:
 if hasattr(MenuItem, "DEADLINES"):
     _MAP_MENU_ITEM_TO_FAB_RESOURCE_TYPE[MenuItem.DEADLINES] = RESOURCE_DAG_RUN
 
-# The Dag bundles view and menu item first ship in Airflow 3.4.0, newer than 
this provider's minimum
-# Airflow. Unmapped, the view is denied to every role, and the menu lookup 
falls back to the raw
-# enum value as a resource name, so the entry would vanish for every FAB 
deployment.
+# The Dag bundles menu item first ships in Airflow 3.4.0 and its view in 
3.4.1, newer than this
+# provider's minimum Airflow. Unmapped, the view is denied to every role. 
Airflow 3.4.0 shows the
+# bundles to anyone who can read a Dag in them, so there the menu entry stays 
on Dag access.
 DAG_BUNDLES_ACCESS_VIEW: AccessView | None = getattr(AccessView, 
"DAG_BUNDLES", None)
 if DAG_BUNDLES_ACCESS_VIEW is not None:
     _MAP_ACCESS_VIEW_TO_FAB_RESOURCE_TYPE[DAG_BUNDLES_ACCESS_VIEW] = 
RESOURCE_DAG_BUNDLE
-if hasattr(MenuItem, "DAG_BUNDLES"):
     _MAP_MENU_ITEM_TO_FAB_RESOURCE_TYPE[MenuItem.DAG_BUNDLES] = 
RESOURCE_DAG_BUNDLE
+elif hasattr(MenuItem, "DAG_BUNDLES"):
+    _MAP_MENU_ITEM_TO_FAB_RESOURCE_TYPE[MenuItem.DAG_BUNDLES] = RESOURCE_DAG
 
 
 class FabAuthManager(BaseAuthManager[User]):
diff --git a/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py 
b/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py
index f494ff2eda1..bd3b9fe3c75 100644
--- a/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py
+++ b/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py
@@ -914,18 +914,19 @@ class TestFabAuthManager:
                 if hasattr(MenuItem, "DEADLINES")
                 else []
             ),
-            # The menu entry follows the bundle resource, not Dag access.
+            # The menu entry follows the bundle resource where Airflow has the 
bundles view, and Dag
+            # access on Airflow 3.4.0, which has only the menu item.
             *(
                 [
                     (
                         [MenuItem.DAG_BUNDLES],
                         [(ACTION_CAN_ACCESS_MENU, RESOURCE_DAG_BUNDLE)],
-                        [MenuItem.DAG_BUNDLES],
+                        [MenuItem.DAG_BUNDLES] if DAG_BUNDLES_ACCESS_VIEW is 
not None else [],
                     ),
                     (
                         [MenuItem.DAG_BUNDLES],
                         [(ACTION_CAN_ACCESS_MENU, RESOURCE_DAG)],
-                        [],
+                        [] if DAG_BUNDLES_ACCESS_VIEW is not None else 
[MenuItem.DAG_BUNDLES],
                     ),
                 ]
                 if hasattr(MenuItem, "DAG_BUNDLES")
diff --git a/providers/keycloak/docs/auth-manager/manage/permissions.rst 
b/providers/keycloak/docs/auth-manager/manage/permissions.rst
index a40e70d4f38..78f70899e64 100644
--- a/providers/keycloak/docs/auth-manager/manage/permissions.rst
+++ b/providers/keycloak/docs/auth-manager/manage/permissions.rst
@@ -120,7 +120,7 @@ You must assign the appropriate Keycloak roles 
(Admin/Op/User/Viewer or SuperAdm
 In multi-team mode, the ``Admin`` role is **team-scoped** (group + role). Only 
``SuperAdmin`` grants global
 admin access across all teams.
 Views over records beyond the Dags a caller can read -- audit log entries not 
tied to a Dag,
-import errors for files with no registered Dag, reparsing such files, and Dag 
bundles -- are checked against the
+import errors for files with no registered Dag, reparsing such files, and Dag 
bundles (from Airflow 3.4.1) -- are checked against the
 ``AdminView`` resource, which the CLI grants to ``SuperAdmin`` only. The other 
views are checked against
 the ``View`` resource, which every team role can read.
 
diff --git a/providers/keycloak/docs/changelog.rst 
b/providers/keycloak/docs/changelog.rst
index bf9ce07373f..41931647051 100644
--- a/providers/keycloak/docs/changelog.rst
+++ b/providers/keycloak/docs/changelog.rst
@@ -26,9 +26,9 @@ Changelog
 ---------
 
 .. note::
-    Airflow 3.4.0 adds a Dag bundles view, which in multi-team mode is checked 
against the
+    Airflow 3.4.1 adds a Dag bundles view, which in multi-team mode is checked 
against the
     ``AdminView`` resource, so only ``SuperAdmin`` holds it. Multi-team 
deployments must upgrade this
-    provider together with Airflow 3.4.0: older releases check the view 
against ``View``, which every
+    provider together with Airflow 3.4.1: older releases check the view 
against ``View``, which every
     team role can read.
 
 0.11.1
diff --git 
a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/cli/commands.py
 
b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/cli/commands.py
index 6548cf53c31..3d567f67369 100644
--- 
a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/cli/commands.py
+++ 
b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/cli/commands.py
@@ -25,6 +25,7 @@ from keycloak import KeycloakAdmin, KeycloakError
 from keycloak.exceptions import KeycloakGetError, KeycloakPostError, 
raise_error_from_response
 
 from airflow.api_fastapi.auth.managers.base_auth_manager import ResourceMethod
+from airflow.api_fastapi.auth.managers.models.resource_details import 
AccessView
 from airflow.api_fastapi.common.types import MenuItem
 from airflow.providers.common.compat.sdk import conf
 from airflow.providers.keycloak.auth_manager.cli.utils import 
dry_run_message_wrap, dry_run_preview
@@ -64,6 +65,10 @@ TEAM_MENU_ITEMS = {
     MenuItem.ASSETS,
     MenuItem.DOCS,
 }
+# Airflow 3.4.0 has the Dag bundles menu item but not its view, and shows the 
bundles to anyone who
+# can read a Dag in them, so there every team role keeps the menu entry.
+if hasattr(MenuItem, "DAG_BUNDLES") and not hasattr(AccessView, "DAG_BUNDLES"):
+    TEAM_MENU_ITEMS.add(MenuItem.DAG_BUNDLES)
 TEAM_ADMIN_MENU_ITEMS = TEAM_MENU_ITEMS | {
     MenuItem.CONNECTIONS,
     MenuItem.POOLS,
diff --git 
a/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py 
b/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py
index ab42ecebf1f..237641b6127 100644
--- a/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py
+++ b/providers/keycloak/tests/unit/keycloak/auth_manager/cli/test_commands.py
@@ -21,6 +21,7 @@ from unittest.mock import Mock, call, patch
 
 import pytest
 
+from airflow.api_fastapi.auth.managers.models.resource_details import 
AccessView
 from airflow.api_fastapi.common.types import MenuItem
 from airflow.cli import cli_parser
 from airflow.providers.keycloak.auth_manager.cli.commands import (
@@ -43,9 +44,13 @@ from airflow.providers.keycloak.auth_manager.resources 
import KeycloakResource
 from tests_common.test_utils.config import conf_vars
 from tests_common.test_utils.version_compat import AIRFLOW_V_3_2_PLUS
 
-EXPECTED_TEAM_MENU_RESOURCES = sorted(["Assets", "Dags", "Docs"])
+# Every team role keeps "Dag Bundles" on Airflow 3.4.0, which has the menu 
item but not its view.
+DAG_BUNDLES_MENU = (
+    ["Dag Bundles"] if hasattr(MenuItem, "DAG_BUNDLES") and not 
hasattr(AccessView, "DAG_BUNDLES") else []
+)
+EXPECTED_TEAM_MENU_RESOURCES = sorted(["Assets", "Dags", "Docs", 
*DAG_BUNDLES_MENU])
 EXPECTED_TEAM_ADMIN_MENU_RESOURCES = sorted(
-    ["Assets", "Connections", "Dags", "Docs", "Pools", "Variables", "XComs"]
+    ["Assets", "Connections", "Dags", "Docs", "Pools", "Variables", "XComs", 
*DAG_BUNDLES_MENU]
 )
 
 

Reply via email to