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.

feat(agentic-provisioning): allow wizard-required scopes (#57509)

Matt Brooker4848bd8e5fd7
diff --git a/ee/api/agentic_provisioning/test/test_scope_validation.py b/ee/api/agentic_provisioning/test/test_scope_validation.py
new file mode 100644
index 000000000000..6cd6a30ac88d
--- /dev/null
+++ b/ee/api/agentic_provisioning/test/test_scope_validation.py
@@ -0,0 +1,33 @@
+import pytest
+
+from ee.api.agentic_provisioning.views import ALLOWED_PROVISIONING_SCOPES, _validate_scopes
+
+
+ "scopes,expected",
+ [
+ ([], []),
+ (["query:read"], ["query:read"]),
+ (["llm_gateway:read", "project:read"], ["llm_gateway:read", "project:read"]),
+ (["dashboard:write", "insight:write"], ["dashboard:write", "insight:write"]),
+ (["query:read", "made_up_scope"], None),
+ (["dashboard:read"], None),
+ (["INSIGHT:READ"], None),
+ # introspection is not a grantable OAuth scope (RFC 7662 endpoint, not a scope) — should be rejected.
+ (["introspection"], None),
+ ],
+)
+def test_validate_scopes(scopes, expected):
+ assert _validate_scopes(scopes) == expected
+
+
+def test_allowlist_covers_wizard_required_scopes():
+ wizard_scopes = {
+ "user:read",
+ "project:read",
+ "llm_gateway:read",
+ "dashboard:write",
+ "insight:write",
+ "query:read",
+ }
+ assert wizard_scopes.issubset(ALLOWED_PROVISIONING_SCOPES)
diff --git a/ee/api/agentic_provisioning/views.py b/ee/api/agentic_provisioning/views.py
index db7e8830fbaf..77a455ad5afd 100644
--- a/ee/api/agentic_provisioning/views.py
+++ b/ee/api/agentic_provisioning/views.py
@@ -2093,12 +2093,15 @@ def _verify_hmac_if_present(request: Request) -> Response | None:
ALLOWED_PROVISIONING_SCOPES = {
"customer_journey:read",
+ "dashboard:write",
"query:read",
"conversation:read",
"conversation:write",
"experiment:read",
"feature_flag:read",
"insight:read",
+ "insight:write",
+ "llm_gateway:read",
"organization:read",
"person:read",
"project:read",