Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(tasks): require task:write scope for connection_token endpoint (#57609)

Vojta Bartošf0e175dc36bb
diff --git a/products/tasks/backend/api.py b/products/tasks/backend/api.py
index 0631480f3763..c135a7a92d9a 100644
--- a/products/tasks/backend/api.py
+++ b/products/tasks/backend/api.py
@@ -1824,7 +1824,7 @@ class TaskRunViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
detail=True,
methods=["get"],
url_path="connection_token",
- required_scopes=["task:read"],
+ required_scopes=["task:write"],
)
def connection_token(self, request, pk=None, **kwargs):
task_run = cast(TaskRun, self.get_object())
diff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.py
index 6496eaeb3c12..1357a92ba115 100644
--- a/products/tasks/backend/tests/test_api.py
+++ b/products/tasks/backend/tests/test_api.py
@@ -4640,6 +4640,7 @@ class TestTasksAPIPermissions(BaseTaskAPITest):
("task:read", "GET", f"/api/projects/@current/tasks/{{task_id}}/", True),
("task:read", "GET", f"/api/projects/@current/tasks/{{task_id}}/runs/", True),
("task:read", "GET", f"/api/projects/@current/tasks/{{task_id}}/runs/{{run_id}}/", True),
+ ("task:read", "GET", f"/api/projects/@current/tasks/{{task_id}}/runs/{{run_id}}/connection_token/", False),
("task:read", "GET", "/api/projects/@current/task_automations/", True),
("task:read", "GET", "/api/projects/@current/task_automations/{automation_id}/", True),
("task:read", "POST", "/api/projects/@current/tasks/", False),
@@ -4654,6 +4655,7 @@ class TestTasksAPIPermissions(BaseTaskAPITest):
("task:write", "POST", f"/api/projects/@current/tasks/{{task_id}}/run/", True),
("task:write", "GET", f"/api/projects/@current/tasks/{{task_id}}/runs/", True),
("task:write", "GET", f"/api/projects/@current/tasks/{{task_id}}/runs/{{run_id}}/", True),
+ ("task:write", "GET", f"/api/projects/@current/tasks/{{task_id}}/runs/{{run_id}}/connection_token/", True),
("task:write", "POST", f"/api/projects/@current/tasks/{{task_id}}/runs/{{run_id}}/start/", True),
("task:write", "GET", "/api/projects/@current/task_automations/", True),
("task:write", "GET", "/api/projects/@current/task_automations/{automation_id}/", True),