Skip to content

fix(controlplane): keep only explicit policies on API tokens - #3823

Merged
jiparis merged 1 commit into
chainloop-dev:mainfrom
jiparis:fix/apitoken-explicit-policies-only
Nov 17, 2026
Merged

jiparis merged 1 commit into
chainloop-dev:mainfrom
jiparis:fix/apitoken-explicit-policies-only

Conversation

@jiparis

@jiparis jiparis commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

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.

View guided diff

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
@chainloop-platform

chainloop-platform Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

Status Policy Material Messages
✅ Passed pr-min-approvals pr-info -
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟢 96% · ⚠️ 1 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 96% 1 ⚠️ 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)

View session details ↗

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% Human

Status 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-allowed ai-coding-session-2514fc -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-2514fc -
⚠️ Failed ai-config-no-secrets ai-coding-session-2514fc Secret (jwt) detected in session content [turn=121, source=tool_result, line=21]: 21 [CHAINLOOP_TRACE_REDACTED:jwt]"
✅ Passed ai-config-mcp-servers-allowed ai-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

View attestation ↗


Powered by Chainloop and Chainloop Trace

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Re-trigger cubic

@jiparis
jiparis merged commit c700275 into chainloop-dev:main Nov 17, 2026
16 of 17 checks passed
@jiparis
jiparis deleted the fix/apitoken-explicit-policies-only branch November 17, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create API tokens with only the policies passed through APITokenWithPolicies

2 participants