You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vincbeck (via GitHub)" <gi...@apache.org> on 2025/10/06 15:15:43 UTC

Re: [PR] feature: Allow batch filtering for dags using Keycloak provider [airflow]

vincbeck commented on code in PR #56433:
URL: https://github.com/apache/airflow/pull/56433#discussion_r2406913311


##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/keycloak_auth_manager.py:
##########
@@ -149,12 +149,70 @@ def is_authorized_dag(
     ) -> bool:
         dag_id = details.id if details else None
         access_entity_str = access_entity.value if access_entity else None
+        team_name = details.team_name if details else None
+        attributes: dict[str, str | None] = {"dag_entity": access_entity_str}
+        if team_name:
+            attributes["team_name"] = team_name
         return self._is_authorized(
             method=method,
             resource_type=KeycloakResource.DAG,
             user=user,
             resource_id=dag_id,
-            attributes={"dag_entity": access_entity_str},
+            attributes=attributes,
+        )
+
+    def is_batch_authorized_dag(

Review Comment:
   I am having hard time understanding this function. Can you please explain what you are trying to achieve here? Also:
    - This function's name is very close to `batch_is_authorized_dag`, that is a method in the auth manager interface. It is confusing
    - This function should be private



##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/keycloak_auth_manager.py:
##########
@@ -149,12 +149,70 @@ def is_authorized_dag(
     ) -> bool:
         dag_id = details.id if details else None
         access_entity_str = access_entity.value if access_entity else None
+        team_name = details.team_name if details else None
+        attributes: dict[str, str | None] = {"dag_entity": access_entity_str}
+        if team_name:
+            attributes["team_name"] = team_name
         return self._is_authorized(
             method=method,
             resource_type=KeycloakResource.DAG,
             user=user,
             resource_id=dag_id,
-            attributes={"dag_entity": access_entity_str},
+            attributes=attributes,

Review Comment:
   nit
   ```suggestion
               attributes=prune_dict({
                 "dag_entity": access_entity_str,
                 "team_name": team_name
               }),
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org