Repository navigation
fix(controlplane): keep only explicit policies on API tokens - #3823
Conversation
A token created with APITokenWithPolicies now stores only the policies passed in, whatever its scope. Organization-scoped tokens no longer get the organization-level policies added on top of an explicit set. Closes chainloop-dev#3822 Assisted-by: Claude Code Signed-off-by: Jose Ignacio Paris Prieto <jiparis@chainloop.dev> Chainloop-Trace-Sessions: 2514fc8f-f006-4934-926f-c6404808d387
PR validation — ✅ 3 passing
AI Session Checks — 🟢 96% ·
|
| Avg score | Sessions | Failing policies | Attribution | Files | Lines | Total Duration |
|---|---|---|---|---|---|---|
| 🟢 96% | 1 | 94% AI / 6% Human | 2 | +28 / -8 | 17m42s |
🟢 96% — 94% AI — ⚠️ 1 policies failing
-
Nov 17, 2026 11:11 UTC · 17m42s · $2.66 · 102 in / 25.1k out · claude-code 2.1.326 (claude-opus-5-5)
Change Summary
-
Stops adding organization-level policies when callers provide explicit token policies. Keeps default-policy behavior unchanged for tokens without custom policies and expands regression coverage across organization, project, and product scopes.
AI Session Overall Score
-
🟢 96% — A focused root-cause fix preserves policy boundaries and is backed by a failing-then-passing regression.
AI Session Analysis Breakdown
-
🟢 98% · scope-discipline
-
🟢 The diff touches only token-policy selection and the directly related integration regression. · High Impact
🟢 97% · solution-quality
-
🟢 The widening guard fixes the root cause while preserving exactly the caller-supplied policy set. · High Impact
🟢 96% · alignment
-
No notes.
🟢 96% · verification
-
🟢 Three-scope regression asserts exact policies, fails before the fix, and passes in the subsequent uncached business-layer suite. · High Impact
🟢 94% · context-and-planning
-
No notes.
🟢 92% · user-trust-signal
-
No notes.
-
File Attribution
██████████████████░░94% AI / 6% HumanStatus Attribution File Lines modified ai app/controlplane/pkg/biz/apitoken_integration_test.go+23 / -5 modified ai app/controlplane/pkg/biz/apitoken.go+5 / -3
Policies (4, 1 failing)
Status Policy Material Messages ✅ Passed ai-config-ai-agents-allowedai-coding-session-2514fc- ✅ Passed ai-config-no-dangerous-commandsai-coding-session-2514fc- ⚠️ Failedai-config-no-secretsai-coding-session-2514fcSecret (jwt) detected in session content [turn=121, source=tool_result, line=21]: 21 [CHAINLOOP_TRACE_REDACTED:jwt]" ✅ Passed ai-config-mcp-servers-allowedai-coding-session-2514fc- -
Security Checks — ✅ 5 passing
✅ secret-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | secrets-detection |
- |
✅ sast-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | owasp-top10-2025 |
- |
| ✅ Passed | sast |
- |
| ✅ Passed | cwe-top25 |
- |
| ✅ Passed | cwe-top26-40-cusp |
- |
Scans not applied (3)
| Scan | Reason |
|---|---|
vulnerability-scan |
no manifest/lockfile changed |
github-actions-scan |
no workflow files changed |
iac-scan |
no IaC files changed |
Powered by Chainloop and Chainloop Trace
When an API token is created with an explicit policy set (
APITokenWithPolicies), the token now carries only those policies, whatever its scope. Before, organization-scoped tokens also got the organization-level policies (API token management and registered integrations) added on top of the explicit set.Tokens created without an explicit policy set keep the current behavior: the default policies, plus the organization-level policies for organization-scoped tokens.
Callers that create organization-scoped tokens with an explicit policy set and need the organization-level policies must now pass them explicitly.
Closes #3822
AI disclosure: this change was produced with the assistance of Claude Code.