Repository navigation
fix(auth): make github/sts compose with default GitHub token injection - #2557
Conversation
The just-shipped github/sts feature (#2546) mints least-privilege tokens and routes git over them via GIT_CONFIG_* insteadOf rewrites, but for Atmos-native go-getter reads (vendor pull, source:, remote import:) CustomGitDetector injected the ambient GITHUB_TOKEN into the URL first. Once the URL carried userinfo, git's insteadOf no longer prefix-matched, silently shadowing the minted token — a second private repo failed to clone with "Repository not found". The only fix was the settings.inject_github_token: false workaround. - Skip URL token injection when a live GIT_CONFIG_* insteadOf already matches the URL's host/owner, so git's rewrite (correct minted token) wins; host/owner-scoped, so non-minted owners still get injected. - resolveToken falls back to live os.Getenv("ATMOS_PRO_GITHUB_TOKEN") (the broker sets it after startup), mirroring pkg/http/client.go. - token_env now defaults to ATMOS_PRO_GITHUB_TOKEN so a single-owner mint bridges to gh/REST and the in-process git path automatically. - Replace the ad-hoc {owner} placeholder with Atmos-standard Go template syntax ({{ .owner }}, plus .host) for token_env. Reproduced first with a simulated-broker e2e test, then fixed. Docs and PRD updated. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughFixes a regression where minted GitHub tokens were overridden by in-process git URL rewriting by (1) detecting broker-exported GIT_CONFIG_* insteadOf rewrites to skip token injection, (2) preferring live ATMOS_PRO_GITHUB_TOKEN, (3) defaulting token_env to ATMOS_PRO_GITHUB_TOKEN, and (4) adding Go-template token_env rendering plus tests/docs. ChangesGitHub STS Token Injection Shadowing Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/auth/integrations/github/sts.go (1)
7-28: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winOrganize imports into three groups per coding guidelines.
The imports should be organized into three groups separated by blank lines: (1) Go stdlib, (2) 3rd-party libraries (excluding cloudposse/atmos), (3) Atmos packages. Currently, all cloudposse/atmos imports are mixed with the stdlib group.
♻️ Proposed fix
import ( "bytes" "context" "encoding/json" "fmt" "net/http" "os" "path/filepath" "strconv" "strings" "text/template" "time" errUtils "github.com/cloudposse/atmos/errors" "github.com/cloudposse/atmos/pkg/auth/integrations" "github.com/cloudposse/atmos/pkg/auth/types" log "github.com/cloudposse/atmos/pkg/logger" "github.com/cloudposse/atmos/pkg/perf" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui" "github.com/cloudposse/atmos/pkg/xdg" )As per coding guidelines: Organize imports in three groups separated by blank lines, sorted alphabetically: (1) Go stdlib, (2) 3rd-party (NOT cloudposse/atmos), (3) Atmos packages. Maintain aliases:
cfg,log,u,errUtils.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/auth/integrations/github/sts.go` around lines 7 - 28, Rearrange the import block into three groups separated by a blank line: first all Go standard library imports (bytes, context, encoding/json, fmt, net/http, os, path/filepath, strconv, strings, text/template, time) sorted alphabetically; second any third‑party imports (none of the github.com/cloudposse/atmos packages) sorted alphabetically; and third all Atmos package imports (errUtils alias, integrations, types, log alias, perf, schema, ui, xdg) sorted alphabetically, preserving existing aliases (`errUtils`, `log`, and any `cfg`/`u` aliases mentioned elsewhere) and keeping a single blank line between each group.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@website/docs/cli/configuration/auth/index.mdx`:
- Line 169: The sentence about exporting the minted token as
ATMOS_PRO_GITHUB_TOKEN is too absolute; change the wording to state that
ATMOS_PRO_GITHUB_TOKEN is exported by default only for single-owner mints (see
token_env), and clarify that multi-owner mints may skip raw export or use
literal names; also keep the note that Atmos prefers ATMOS_PRO_GITHUB_TOKEN over
ATMOS_GITHUB_TOKEN and GITHUB_TOKEN and that when a github/sts GIT_CONFIG_*
rewrite already covers a repo owner Atmos skips URL token injection so git's
rewrite wins and settings.inject_github_token can remain true.
---
Outside diff comments:
In `@pkg/auth/integrations/github/sts.go`:
- Around line 7-28: Rearrange the import block into three groups separated by a
blank line: first all Go standard library imports (bytes, context,
encoding/json, fmt, net/http, os, path/filepath, strconv, strings,
text/template, time) sorted alphabetically; second any third‑party imports (none
of the github.com/cloudposse/atmos packages) sorted alphabetically; and third
all Atmos package imports (errUtils alias, integrations, types, log alias, perf,
schema, ui, xdg) sorted alphabetically, preserving existing aliases (`errUtils`,
`log`, and any `cfg`/`u` aliases mentioned elsewhere) and keeping a single blank
line between each group.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 68b6a7d4-f428-4317-a562-b079ace9caf2
📒 Files selected for processing (13)
docs/fixes/2026-06-01-github-sts-token-injection-shadowing.mddocs/prd/atmos-pro-sts.mdpkg/auth/integrations/github/sts.gopkg/auth/integrations/github/sts_errors_test.gopkg/auth/integrations/github/sts_test.gopkg/downloader/atmos_pro_token_test.gopkg/downloader/broker_insteadof_helper_test.gopkg/downloader/broker_insteadof_test.gopkg/downloader/custom_git_detector.gopkg/downloader/token_injection_test.gopkg/schema/schema_auth.gowebsite/docs/cli/commands/auth/auth-env.mdxwebsite/docs/cli/configuration/auth/index.mdx
Address CodeRabbit review on PR #2557: the default-export sentence read as unconditional, but the raw token export only happens for a single-owner mint when token_env is left at its default. Multi-owner mints under the literal default skip the bare var and rely on the GIT_CONFIG_* rewrites. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@NOTICE`:
- Line 635: Replace the "URL: Unknown" entry for the dependency identifier
"dario.cat/mergo" in the NOTICE file with the upstream license link or the
vendored license path; specifically update the URL for dario.cat/mergo to point
to the project's license (for example the upstream LICENSE at
https://github.com/imdario/mergo/blob/master/LICENSE or the local vendored
license file path) so the NOTICE entry for dario.cat/mergo contains a concrete,
traceable license URL.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2557 +/- ##
==========================================
+ Coverage 78.81% 78.83% +0.01%
==========================================
Files 1195 1195
Lines 114221 114267 +46
==========================================
+ Hits 90025 90079 +54
+ Misses 19247 19234 -13
- Partials 4949 4954 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The NOTICE generator (scripts/generate-notice.sh) resolves each dependency's license URL via `go-licenses report`, which does a network fetch to map a module's import path to its source repo. For vanity import paths whose source lives on a different host (dario.cat/mergo -> github.com/imdario/mergo, inet.af/netaddr -> github.com/inetaf/netaddr) that fetch is flaky, so a regen run that can't reach the vanity domain emits "URL: Unknown" and produces a spurious NOTICE diff (which dependency-review.yml then fails on). Add a deterministic override step: for the affected vanity modules, rebuild the LICENSE URL from the version already pinned in go.mod (`go list -m`, no network). Tags are used verbatim; pseudo-versions resolve to their trailing commit hash so the GitHub blob URL is valid. The override is a plain newline-delimited list (not a bash 4 associative array) so it works on macOS's stock bash 3.2. NOTICE: inet.af/netaddr URL is now a concrete link instead of "Unknown"; dario.cat/mergo is unchanged (the override reproduces its existing URL). Co-Authored-By: Claude Opus 4.8 <[email protected]>
1980c79 to
65d652d
Compare
Octo-STS is an external project; referencing it as a comparison point in shipped code comments, the blog post, and user-facing docs is undesirable. Reword those mentions to describe the github/sts raw-token export capability generically (mint a token, hand it to any GitHub-token consumer). The only surviving Octo-STS reference now lives in a new References section of the PRD, credited as inspiration rather than framed as parity. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.221.0-rc.3. |
what
github/sts-minted GitHub tokens:CustomGitDetectornow skips URL token injection when a liveGIT_CONFIG_*insteadOfrewrite already matches the URL's host/owner, so git's rewrite (carrying the correct least-privilege token) wins.ATMOS_PRO_GITHUB_TOKENbridge consistent:resolveTokenfalls back to the live env var (which the broker sets after startup), mirroringpkg/http/client.go.token_envtoATMOS_PRO_GITHUB_TOKEN(was empty) so a single-owner mint reachesgh/REST and Atmos's in-process git path automatically.{owner}placeholder with Atmos's standard Go-template syntax ({{ .owner }}, plus.host); update docs, PRD, and add adocs/fixes/write-up.why
import:from a second private repo failed withremote: Repository not found— the minted token was correct, but the ambientGITHUB_TOKENwas being injected into the URL ahead of it, defeating git'sinsteadOfrewrite. The only fix was thesettings.inject_github_token: falseworkaround.github/sts(introduced in feat(auth): Atmos Pro STS — JIT GitHub token broker for CI #2546) compose with the defaultsettings.inject_github_token: true, so it "just works" with no workaround. Reproduced first with a simulated-broker e2e test, then fixed.references
github/stsfeature shipped in feat(auth): Atmos Pro STS — JIT GitHub token broker for CI #2546docs/fixes/2026-06-01-github-sts-token-injection-shadowing.md(root cause, fix, and why this is a fix doc rather than a changelog entry)docs/prd/atmos-pro-sts.mdSummary by CodeRabbit
Bug Fixes
New Features
Documentation
Tests
Chores