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


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py:
##########
@@ -378,7 +384,10 @@ def get_hitl_detail_try_detail(
     "/hitlDetails",
     status_code=status.HTTP_200_OK,
     responses=create_openapi_http_exception_doc([status.HTTP_400_BAD_REQUEST]),
-    dependencies=[Depends(requires_access_dag(method="GET", 
access_entity=DagAccessEntity.HITL_DETAIL))],
+    dependencies=[
+        Depends(requires_access_dag(method="GET", 
access_entity=DagAccessEntity.HITL_DETAIL)),
+        Depends(requires_access_dag(method="GET", 
access_entity=DagAccessEntity.TASK_INSTANCE)),

Review Comment:
   With `dag_id=~`, which is what the Required Actions page and the dashboard 
call, this check runs once with no Dag, and `readable_ti_filter` only keeps the 
Dags the user can read, not the Dags whose task instances they can read. With 
an auth manager that has per-Dag rules, a user with HITL Detail read on Dags A 
and B but Task Instance read only on A still gets B's task instances. The task 
instance list route has the same gap, so we can do it as a follow-up, but 
should we filter on Task Instance read per Dag here?



##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_hitl.py:
##########
@@ -477,6 +478,27 @@ def sample_update_payload() -> dict[str, Any]:
     return {"chosen_options": ["Approve"], "params_input": {"input_1": 2}}
 
 
[email protected](
+    "url",
+    [
+        f"/dags/{DAG_ID}/dagRuns/test/taskInstances/{TASK_ID}/-1/hitlDetails",
+        
f"/dags/{DAG_ID}/dagRuns/test/taskInstances/{TASK_ID}/-1/hitlDetails/tries/1",
+        f"/dags/{DAG_ID}/dagRuns/test/hitlDetails",

Review Comment:
   nit: can you add the `~` wildcard as well? That is how the UI calls this 
endpoint.
   
   ```suggestion
           f"/dags/{DAG_ID}/dagRuns/test/hitlDetails",
           "/dags/~/dagRuns/~/hitlDetails",
   ```



##########
airflow-core/newsfragments/77794.significant.rst:
##########
@@ -0,0 +1,13 @@
+HITL detail read endpoints now also require Task Instance read permission
+
+For security reasons, the permission model of the HITL detail read endpoints 
changed. Their
+responses include the task instance, so on top of HITL Detail read permission 
they now require
+the same Task Instance read permission as the task instance endpoints:
+
+- ``GET 
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails``
+- ``GET 
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails/tries/{try_number}``
+- ``GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/hitlDetails``
+
+Users whose role grants HITL Detail read but not Task Instance read on a Dag 
now get a ``403``
+from these endpoints, including in the "Required Actions" page of the UI. 
Grant Task Instance

Review Comment:
   The Required Actions menu item is still gated on HITL Detail only (FAB maps 
`MenuItem.REQUIRED_ACTIONS` to `HITL Detail`), so these users still see the 
menu and land on a page that fails. Should we also hide it when Task Instance 
read is missing?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to