Skip to content

feat: add CircleCI OIDC detector - #305

Merged
cloudsmith-iduffy merged 5 commits into
masterfrom
iduffy/circleci
Jun 10, 2026
Merged

feat: add CircleCI OIDC detector#305
cloudsmith-iduffy merged 5 commits into
masterfrom
iduffy/circleci

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Contributor

Summary

Adds CircleCI to the OIDC credential auto-discovery chain. When running in CircleCI, the CLI reads the OIDC token from CIRCLE_OIDC_TOKEN_V2 (preferred) or CIRCLE_OIDC_TOKEN and exchanges it for a short-lived Cloudsmith API token — no static credentials required.

  • New CircleCIDetector (cloudsmith_cli/core/credentials/oidc/detectors/circleci.py), registered first in the detector chain.
  • Detection guards on CIRCLECI == "true" plus presence of a token env var.
  • Unit tests covering detection and token selection (V2 preference, V1 fallback, error cases).
  • CHANGELOG entry.

Verification

Verified end-to-end against a live public CircleCI pipeline (cloudsmith-iduffy/cloudsmith-cli-oidc-test): detection → OIDC token fetch → Cloudsmith exchange → authenticated whoami/list repos round-trip succeeds.

OIDC token claims observed:

  • iss: https://oidc.circleci.com/org/<org_id>
  • aud: <org_id> (the CircleCI org UUID; not customizable for the preset env-var token)
  • sub (V2): org/<org_id>/project/<project_id>/user/<user_id>/vcs-origin/<vcs_origin>/vcs-ref/<vcs_ref>

Public proof pipeline: https://app.circleci.com/pipelines/github/cloudsmith-iduffy/cloudsmith-cli-oidc-test

🤖 Generated with Claude Code

CopilotAI review requested due to automatic review settings June 8, 2026 22:16
@cloudsmith-iduffy
cloudsmith-iduffy requested a review from a team as a code ownerJune 8, 2026 22:16

CopilotAI 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.

Pull request overview

  • Adds CircleCI support to the CLI’s OIDC credential auto-discovery so CircleCI jobs can exchange a CircleCI-provided OIDC JWT for a short-lived Cloudsmith API token (avoiding static credentials).

Changes:

  • Introduces a new CircleCIDetector that reads CIRCLE_OIDC_TOKEN_V2 (preferred) or CIRCLE_OIDC_TOKEN.
  • Registers CircleCI first in the OIDC detector chain.
  • Adds unit tests for detection/token selection and documents the feature in the changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

FileDescription
cloudsmith_cli/core/credentials/oidc/detectors/circleci.pyAdds CircleCI environment detection and token retrieval logic for OIDC.
cloudsmith_cli/core/credentials/oidc/detectors/init.pyRegisters the CircleCI detector in the environment detection chain.
cloudsmith_cli/core/tests/test_circleci_detector.pyAdds unit tests validating detection and token selection behavior.
CHANGELOG.mdDocuments the new CircleCI OIDC auto-discovery capability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadcloudsmith_cli/core/credentials/oidc/detectors/circleci.py Outdated
Comment threadcloudsmith_cli/core/credentials/oidc/detectors/circleci.py
Add CircleCI to OIDC credential auto-discovery. When running in CircleCI,
the CLI reads the OIDC token from the CIRCLE_OIDC_TOKEN_V2 (preferred) or
CIRCLE_OIDC_TOKEN environment variable and exchanges it for a Cloudsmith
access token. Works out of the box with no extra dependencies.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudsmith-iduffy
cloudsmith-iduffy merged commit 8a12a03 into masterJun 10, 2026
40 checks passed
@cloudsmith-iduffy
cloudsmith-iduffy deleted the iduffy/circleci branch June 10, 2026 17:17
@BartoszBlizniakBartoszBlizniak mentioned this pull request Jun 11, 2026
6 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@cloudsmith-iduffy@BartoszBlizniak