@@ -103,14 +103,16 @@ def _init_opa_resources(self) -> None:
103103 """
104104 Set up the OPA cache and HTTP session.
105105
106- Idempotent so it can be called from both ``init`` (FastAPI api-server)
107- and ``init_flask_resources`` (Flask AppBuilder) — only one of the two
108- runs depending on the Airflow component.
106+ Called from both ``init`` (FastAPI api-server) and
107+ ``init_flask_resources`` (Flask AppBuilder). In Airflow 3 both run
108+ during a single api-server startup but on *different*
109+ OpaFabAuthManager instances — ``init_appbuilder`` calls
110+ ``create_auth_manager()`` again, which constructs a fresh instance.
111+ The api-server instance is reachable via
112+ ``request.app.state.auth_manager``; the FAB instance is returned by
113+ ``get_auth_manager()``. Both need their own cache and session.
109114 """
110115
111- if getattr (self , "opa_cache" , None ) is not None :
112- return
113-
114116 Stats .incr (METRIC_NAME_OPA_CACHE_LIMIT_REACHED , count = 0 )
115117
116118 self .opa_cache = Cache (
@@ -590,11 +592,18 @@ def get_authorized_dag_ids(
590592 # FabAuthManager's implementation consults the user's FAB DB role
591593 # permissions and bypasses is_authorized_dag entirely, which makes any
592594 # user without a FAB role (e.g. the default Public role) see an empty
593- # DAG list even when OPA would allow them. Re-implement the
594- # BaseAuthManager default: list all DAG ids and filter them via
595- # is_authorized_dag → OPA.
595+ # DAG list even when OPA would allow them. List all DAG ids and filter
596+ # them via is_authorized_dag → OPA directly, without going through
597+ # filter_authorized_dag_ids — the Fab base class may add a DB-backed
598+ # override of that method in the future.
596599 dag_ids = {dag .dag_id for dag in session .execute (select (DagModel .dag_id ))}
597- return self .filter_authorized_dag_ids (dag_ids = dag_ids , method = method , user = user )
600+ return {
601+ dag_id
602+ for dag_id in dag_ids
603+ if self .is_authorized_dag (
604+ method = method , details = DagDetails (id = dag_id ), user = user
605+ )
606+ }
598607
599608 @override
600609 def filter_authorized_menu_items (
0 commit comments