This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun 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 fd778a4e5ad Require task instance read on the HITL detail read routes
(#77794)
fd778a4e5ad is described below
commit fd778a4e5ad5dac92cb7aeb59ba72d7e275241ed
Author: Pierre Jeambrun <[email protected]>
AuthorDate: Tue Dec 1 14:22:03 2026 +0100
Require task instance read on the HITL detail read routes (#77794)
* Require task instance read on the HITL detail read routes
These routes return the task instance along with the HITL detail, so a
user must be allowed to read task instances, as on the task instance
routes, not only HITL details.
* Add a newsfragment for the HITL detail read permission change
The HITL detail read endpoints now also require Task Instance read, which
can break roles that only had HITL Detail read, so users need a note
before upgrading.
* Cover the granted and wildcard cases of the HITL Task Instance read check
The UI lists HITL details through the ~ wildcard, and a check that only
proves denial would not catch one that also blocks users granted both
permissions. FAB users also need DAG Runs read for Task Instance read, which
the upgrade note left out.
* Hide the Required Actions menu from FAB users without Task Instance read
The Required Actions page now needs Task Instance read, so users with only
HITL Detail menu access were shown a menu entry leading to a failing page. The
upgrade note also named FAB resources, which other auth managers do not have.
* Move the FAB Required Actions menu change to its own PR
The FAB provider is released separately from Airflow, so its menu change is
reviewed and shipped on its own.
---
airflow-core/docs/security/api_permissions_ref.rst | 12 +++++++++
airflow-core/newsfragments/77794.significant.rst | 13 +++++++++
.../api_fastapi/core_api/routes/public/hitl.py | 15 ++++++++---
.../core_api/routes/public/test_hitl.py | 31 ++++++++++++++++++++++
providers/fab/docs/auth-manager/access-control.rst | 12 +++++++++
5 files changed, 80 insertions(+), 3 deletions(-)
diff --git a/airflow-core/docs/security/api_permissions_ref.rst
b/airflow-core/docs/security/api_permissions_ref.rst
index 6fd7c9c2a0f..b7a3e2bdef8 100644
--- a/airflow-core/docs/security/api_permissions_ref.rst
+++ b/airflow-core/docs/security/api_permissions_ref.rst
@@ -334,6 +334,10 @@ source code so it stays up to date as endpoints are added
or changed.
- ``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/hitlDetails``
- ``DAG.HITL_DETAIL``
- ``GET``
+ * - ``GET``
+ - ``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/hitlDetails``
+ - ``DAG.TASK_INSTANCE``
+ - ``GET``
* - ``PATCH``
-
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskGroupInstances/{group_id}``
- ``DAG.TASK_INSTANCE``
@@ -462,6 +466,10 @@ source code so it stays up to date as endpoints are added
or changed.
-
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails``
- ``DAG.HITL_DETAIL``
- ``GET``
+ * - ``GET``
+ -
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails``
+ - ``DAG.TASK_INSTANCE``
+ - ``GET``
* - ``PATCH``
-
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails``
- ``DAG.HITL_DETAIL``
@@ -470,6 +478,10 @@ source code so it stays up to date as endpoints are added
or changed.
-
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails/tries/{try_number}``
- ``DAG.HITL_DETAIL``
- ``GET``
+ * - ``GET``
+ -
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails/tries/{try_number}``
+ - ``DAG.TASK_INSTANCE``
+ - ``GET``
* - ``GET``
-
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/tries``
- ``DAG.TASK_INSTANCE``
diff --git a/airflow-core/newsfragments/77794.significant.rst
b/airflow-core/newsfragments/77794.significant.rst
new file mode 100644
index 00000000000..0e83359132f
--- /dev/null
+++ b/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
+read permission on ``DagAccessEntity.TASK_INSTANCE``, like 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 authorized to read HITL details but not
``DagAccessEntity.TASK_INSTANCE`` on a Dag now get a
+``403`` from these endpoints, including in the "Required Actions" page of the
UI. Grant them read
+access on ``DagAccessEntity.TASK_INSTANCE`` for those Dags to keep their
access.
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py
index ed627e4afc0..3260ad6ddde 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py
@@ -346,7 +346,10 @@ def update_hitl_detail(
responses=create_openapi_http_exception_doc(
[status.HTTP_400_BAD_REQUEST, status.HTTP_404_NOT_FOUND,
status.HTTP_409_CONFLICT]
),
- 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)),
+ ],
)
def get_hitl_detail(
dag_id: str,
@@ -384,7 +387,10 @@ def get_hitl_detail(
responses=create_openapi_http_exception_doc(
[status.HTTP_400_BAD_REQUEST, status.HTTP_404_NOT_FOUND,
status.HTTP_409_CONFLICT]
),
- 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)),
+ ],
)
def get_hitl_detail_try_detail(
dag_id: str,
@@ -421,7 +427,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)),
+ ],
)
def get_hitl_details(
dag_id: str,
diff --git
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_hitl.py
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_hitl.py
index ceecb508705..03988aaa651 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_hitl.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_hitl.py
@@ -30,6 +30,7 @@ from sqlalchemy.orm import Session
from airflow._shared.serialization import CLASSNAME, FORBIDDEN_XCOM_KEYS
from airflow._shared.timezones.timezone import utc, utcnow
+from airflow.api_fastapi.auth.managers.models.resource_details import
DagAccessEntity
from airflow.api_fastapi.core_api.routes.public import hitl as hitl_routes
from airflow.models.dag import DagModel
from airflow.models.dagbundle import DagBundleModel
@@ -504,6 +505,36 @@ 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/0",
+ f"/dags/{DAG_ID}/dagRuns/test/hitlDetails",
+ "/dags/~/dagRuns/~/hitlDetails",
+ ],
+)
[email protected](("task_instance_readable", "expected_status"),
[(False, 403), (True, 200)])
[email protected]("sample_hitl_detail")
[email protected](
+
"airflow.api_fastapi.auth.managers.simple.simple_auth_manager.SimpleAuthManager.is_authorized_dag",
+ autospec=True,
+)
+def test_hitl_get_requires_task_instance_read(
+ mock_is_authorized_dag, test_client, url, task_instance_readable,
expected_status
+):
+ """The responses embed the task instance, so they need the access the task
instance routes need."""
+ mock_is_authorized_dag.side_effect = lambda _self, *, method, user,
access_entity=None, details=None: (
+ task_instance_readable or access_entity is not
DagAccessEntity.TASK_INSTANCE
+ )
+
+ assert test_client.get(url).status_code == expected_status
+ assert any(
+ call.kwargs["access_entity"] is DagAccessEntity.TASK_INSTANCE
+ for call in mock_is_authorized_dag.call_args_list
+ )
+
+
class TestUpdateHITLDetailEndpoint:
def test_response_rejects_attempt_archived_after_lookup(
self,
diff --git a/providers/fab/docs/auth-manager/access-control.rst
b/providers/fab/docs/auth-manager/access-control.rst
index 1482504f4ad..7e4a5f7e19b 100644
--- a/providers/fab/docs/auth-manager/access-control.rst
+++ b/providers/fab/docs/auth-manager/access-control.rst
@@ -508,6 +508,10 @@ Stable API Permissions
- GET
- DAGs.can_read
- Viewer
+ * - ``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/hitlDetails``
+ - GET
+ - DAGs.can_read, DAG Runs.can_read, Task Instances.can_read
+ - Viewer
* -
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskGroupInstances/{group_id}``
- PATCH
- DAGs.can_edit, DAG Runs.can_edit, Task Instances.can_edit
@@ -636,6 +640,10 @@ Stable API Permissions
- GET
- DAGs.can_read
- Viewer
+ * -
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails``
+ - GET
+ - DAGs.can_read, DAG Runs.can_read, Task Instances.can_read
+ - Viewer
* -
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails``
- PATCH
- DAGs.can_edit
@@ -644,6 +652,10 @@ Stable API Permissions
- GET
- DAGs.can_read
- Viewer
+ * -
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/hitlDetails/tries/{try_number}``
+ - GET
+ - DAGs.can_read, DAG Runs.can_read, Task Instances.can_read
+ - Viewer
* -
``/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/tries``
- GET
- DAGs.can_read, DAG Runs.can_read, Task Instances.can_read