Uh oh!
There was an error while loading. Please reload this page.
feat: add GitLab CI OIDC detector - #302
Conversation
There was a problem hiding this comment.
Pull request overview
Adds GitLab CI/CD as a first-class OIDC auto-discovery environment for the CLI’s credential resolution chain, enabling GitLab pipelines to authenticate to Cloudsmith using a GitLab-minted OIDC JWT (instead of a static API key).
Changes:
- Added a
GitLabCIDetectorthat detects GitLab CI and retrieves an OIDC JWT fromCLOUDSMITH_OIDC_TOKEN(with legacy fallbacks). - Registered the GitLab detector ahead of the AWS detector in the OIDC environment detection order.
- Added unit tests for detection behavior and token retrieval precedence, and documented GitLab CI OIDC usage in the README.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Documents GitLab CI OIDC configuration and usage example. |
| cloudsmith_cli/core/tests/test_gitlab_ci_detector.py | Adds unit tests for GitLab CI detection and token selection behavior. |
| cloudsmith_cli/core/credentials/oidc/detectors/gitlab_ci.py | Implements the GitLab CI OIDC environment detector. |
| cloudsmith_cli/core/credentials/oidc/detectors/init.py | Registers GitLab CI detector ahead of AWS in the detection chain. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
fcd9f7e to
2777f92CompareUh oh!
There was an error while loading. Please reload this page.
2777f92 to
95748efCompareAdd GitLab CI to OIDC credential auto-discovery. When running in GitLab CI/CD, the CLI reads the OIDC token from CLOUDSMITH_OIDC_TOKEN (configured via id_tokens in .gitlab-ci.yml, with legacy fallbacks to CI_JOB_JWT_V2 and CI_JOB_JWT) 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>
95748ef to
83faa10CompareUh oh!
There was an error while loading. Please reload this page.
Summary
Adds a GitLab CI environment detector to the OIDC credential auto-discovery chain. When the CLI runs inside a GitLab pipeline, it reads an OIDC JWT minted by GitLab's
id_tokensconfiguration and exchanges it for a short-lived Cloudsmith API token — no static API key required.Behaviour
GITLAB_CI=trueplus a token environment variable.CLOUDSMITH_OIDC_TOKEN, falling back to the legacyCI_JOB_JWT_V2/CI_JOB_JWTvariables.Usage
The
audmust behttps://api.cloudsmith.io/openid/<org>— that is the audience the Cloudsmith OIDC endpoint validates.Testing
GITLAB_CIflag) and token retrieval (preference order, legacy fallback, missing-token error).black/isort/flake8/pylintclean.POST /openid/<org>/with the service slug, andcloudsmith whoamireturnedis_authenticated: trueas the service account — authenticating purely via OIDC with no API key.🤖 Generated with Claude Code