Skip to content

feat(auth): Atmos Pro STS — JIT GitHub token broker for CI - #2546

Merged
Andriy Knysh (aknysh) merged 10 commits into
mainfrom
osterman/atmos-pro-github-token
Jun 1, 2026
Merged

Andriy Knysh (aknysh) merged 10 commits into
mainfrom
osterman/atmos-pro-github-token

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented May 29, 2026 •

Copy link
Copy Markdown
Member

what

  • Add a new auth provider kind: atmos/pro that authenticates the Atmos CLI to Atmos Pro by federating the GitHub Actions runner's OIDC token into an Atmos Pro session JWT (v1 is OIDC-only).
  • Add a new auth integration kind: github/sts — a just-in-time GitHub token broker for CI. On login it mints short-lived, scoped GitHub App installation tokens via POST /api/v1/sts, materializes them as per-owner GIT_CONFIG_* URL rewrites (env or file mode), and revokes them at command-end (via atmos auth exec in CI) and on atmos auth logout.
  • Add a passthrough kind: atmos/pro identity, a keyring-registered ProCredentials type, realm scoping for integration state, and via.provider binding for integrations (in addition to via.identity).
  • Add ATMOS_PRO_GITHUB_TOKEN, preferred by Atmos-native git operations (vendoring, source: provisioning, go-getter) ahead of ATMOS_GITHUB_TOKEN/GITHUB_TOKEN.
  • Add the PRD (docs/prd/atmos-pro-sts.md), a changelog blog post, a shipped roadmap milestone, and configuration docs; full unit-test coverage for the provider, identity, integration, keyring round-trip, via.provider matching, revoke gating, and token precedence.

why

  • Fetching private Terraform modules, Atmos source: components, and vendored artifacts in CI today requires a long-lived, over-privileged GitHub credential (PAT, machine user, or deploy key) sitting in a CI secret — a standing breach risk that can't be scoped per-run.
  • Atmos Pro STS replaces that with least-privilege, deny-by-default, short-lived tokens minted at the start of a run and revoked at the end — with zero .tf changes (the injected GIT_CONFIG_* rewrites are honored by both go-getter and Terraform's native git), and multi-org support because tokens are minted per (installation, permission-set).
  • Built into Atmos CLI core (CI-native, OIDC-aware) rather than as a GitHub Action, modeled on the existing aws/ecr/aws/eks integrations; the workflow only needs permissions: id-token: write.

references

  • PRD: docs/prd/atmos-pro-sts.md (includes deferred Future Work: moving Pro connection config under auth, unifying pkg/pro onto auth-issued sessions, and broadening command-end revoke beyond atmos auth exec)
  • Changelog: website/blog/2026-05-29-atmos-pro-github-sts.mdx

Summary by CodeRabbit

  • New Features

    • Atmos Pro GitHub token broker: new atmos/pro provider + github/sts integration for just-in-time GitHub tokens (env or git-config modes) with realm-scoped state and optional token export.
    • ATMOS_PRO_GITHUB_TOKEN added as preferred GitHub token source.
    • CI-gated automatic token revocation on command exit/logout.
    • Ambient credential broker registry to auto-provision env vars for remote reads.
  • Documentation

    • PRD, docs, and blog post for Atmos Pro STS and usage guidance.

Add two new `atmos auth` kinds that let CI authenticate to private GitHub
repositories with just-in-time, least-privilege, short-lived tokens and zero
`.tf` changes:

- Provider `kind: atmos/pro` federates the GitHub Actions OIDC token into an
  Atmos Pro session JWT (reuses pkg/pro exchange; audience parameterized).
- Integration `kind: github/sts` mints scoped GitHub App installation tokens
  via POST /api/v1/sts, injects per-owner GIT_CONFIG_* rewrites (env or file
  mode) so vendor pull, source components, and terraform init of private
  git:: modules just work, then revokes them at command-end and on logout.

Supporting changes: ProCredentials type (keyring-registered), realm plumbed
into integrations, via.provider binding for integrations, ATMOS_PRO_GITHUB_TOKEN
for go-getter, PRD, blog changelog, roadmap milestone, and docs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@atmos-pro

atmos-pro Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label May 29, 2026
@github-actions github-actions Bot added the size/l Large size PR label May 29, 2026
@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b41ff710-5b59-4654-ade3-b41aacc47ebe

📥 Commits

Reviewing files that changed from the base of the PR and between 05a4884 and 41446b3.

📒 Files selected for processing (26)
  • cmd/toolchain/toolchain.go
  • docs/prd/atmos-pro-sts.md
  • errors/errors.go
  • examples/mcp-for-ai-coding-assistants/README.md
  • lychee.toml
  • pkg/auth/integrations/github/sts.go
  • pkg/auth/integrations/github/sts_test.go
  • pkg/config/adapters/adapters_test.go
  • pkg/config/adapters/gogetter_adapter.go
  • pkg/config/adapters/local_adapter.go
  • pkg/config/adapters/mock_adapter.go
  • pkg/config/import_adapter.go
  • pkg/config/import_adapter_registry.go
  • pkg/config/import_adapter_registry_test.go
  • pkg/config/import_test.go
  • pkg/config/import_test_helpers_test.go
  • pkg/config/imports.go
  • pkg/config/imports_error_paths_test.go
  • pkg/config/load.go
  • pkg/http/client.go
  • pkg/http/client_test.go
  • pkg/schema/schema_auth.go
  • website/blog/2026-05-29-atmos-pro-github-sts.mdx
  • website/docs/cli/commands/auth/auth-env.mdx
  • website/docs/cli/configuration/auth/index.mdx
  • website/src/data/roadmap.js
💤 Files with no reviewable changes (4)
  • website/docs/cli/commands/auth/auth-env.mdx
  • website/src/data/roadmap.js
  • website/blog/2026-05-29-atmos-pro-github-sts.mdx
  • website/docs/cli/configuration/auth/index.mdx
✅ Files skipped from review due to trivial changes (2)
  • examples/mcp-for-ai-coding-assistants/README.md
  • lychee.toml
🚧 Files skipped from review as they are similar to previous changes (15)
  • pkg/config/import_test.go
  • pkg/config/import_adapter.go
  • pkg/config/import_adapter_registry_test.go
  • pkg/config/imports.go
  • pkg/schema/schema_auth.go
  • errors/errors.go
  • cmd/toolchain/toolchain.go
  • pkg/config/imports_error_paths_test.go
  • pkg/config/adapters/gogetter_adapter.go
  • pkg/config/adapters/mock_adapter.go
  • pkg/http/client_test.go
  • pkg/http/client.go
  • pkg/config/import_test_helpers_test.go
  • pkg/config/adapters/adapters_test.go
  • pkg/auth/integrations/github/sts.go

📝 Walkthrough

Walkthrough

Introduces Atmos Pro CI credential brokering: an atmos/pro provider exchanging GitHub Actions OIDC for Pro session JWTs, a github/sts integration that mints/revokes per-owner GitHub tokens and exports git config env or file, a broker registry for CI lazy provisioning, manager APIs for environment/revocation, command/terraform wiring, schema/keyring/downloader updates, plus tests and docs.

Changes

Atmos Pro STS Integration

Layer / File(s) Summary
All changed checkpoints
entire PR (see hidden artifact)
Full set of code, tests, docs, and config to implement Atmos Pro STS: provider/identity, GitHub STS integration, broker registry, manager APIs, command/terraform wiring, schema and keyring support, downloader/token precedence, and comprehensive tests/docs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • cloudposse/atmos#1278: Related changes to pkg/pro/api_client.go implementing/reworking GitHub OIDC token exchange and audience-aware helpers.

Suggested reviewers

  • aknysh
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/atmos-pro-github-token

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
pkg/auth/credentials/keyring_system.go (1)

87-89: 💤 Low value

Consider adding debug logging for Pro credentials.

AWS and GCP credentials include debug logging in Store (lines 57-70, 71-83). Adding similar logging for ProCredentials would improve observability and maintain consistency across credential types.

🤖 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/credentials/keyring_system.go` around lines 87 - 89, The Store
branch handling types.ProCredentials lacks the debug logging present for AWS/GCP
credentials; inside the Store function's case for *types.ProCredentials (where
typ is set to "atmos-pro" and raw, err = json.Marshal(c)), add the same
debug/trace log statement used in the AWS/GCP branches to log the credential
type and the marshaled payload (using the same logger used elsewhere in
keyring_system.go) so Pro credentials are logged consistently and any marshal
errors are still captured and returned.
🤖 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 `@pkg/auth/integrations/github/sts_test.go`:
- Around line 292-295: The helper itoa only handles single-digit integers (it
returns string(rune('0' + i))) which breaks for i >= 10; replace its
implementation to use strconv.Itoa so it returns the proper decimal string for
any int. Update the itoa function in pkg/auth/integrations/github/sts_test.go to
import strconv and call strconv.Itoa(i), ensuring tests still build and run.

In `@pkg/auth/types/pro_credentials.go`:
- Around line 30-37: The current ProCredentials.IsExpired implementation treats
unparseable or missing expirations as not expired; update
ProCredentials.IsExpired (and mention GetExpiration/Validate/ErrNotImplemented)
to fail-closed: return true when GetExpiration returns an error or nil (so
malformed tokens are treated as expired), add a brief inline comment explaining
this intentional fail-closed behavior to avoid unnecessary backend calls, and/or
add package-level doc in the pkg/auth/types package describing the validation
contract and why Validate still returns ErrNotImplemented if applicable.

---

Nitpick comments:
In `@pkg/auth/credentials/keyring_system.go`:
- Around line 87-89: The Store branch handling types.ProCredentials lacks the
debug logging present for AWS/GCP credentials; inside the Store function's case
for *types.ProCredentials (where typ is set to "atmos-pro" and raw, err =
json.Marshal(c)), add the same debug/trace log statement used in the AWS/GCP
branches to log the credential type and the marshaled payload (using the same
logger used elsewhere in keyring_system.go) so Pro credentials are logged
consistently and any marshal errors are still captured and returned.
🪄 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: bbb40393-b0c7-4087-bc35-cb5959c13aa6

📥 Commits

Reviewing files that changed from the base of the PR and between ac6321c and 317662e.

📒 Files selected for processing (43)
  • cmd/auth/exec.go
  • cmd/auth/exec_test.go
  • docs/prd/atmos-pro-sts.md
  • errors/errors.go
  • internal/exec/terraform_output_utils.go
  • pkg/auth/credentials/keyring_file.go
  • pkg/auth/credentials/keyring_memory.go
  • pkg/auth/credentials/keyring_system.go
  • pkg/auth/credentials/store_test.go
  • pkg/auth/factory/factory.go
  • pkg/auth/hooks_test.go
  • pkg/auth/identities/atmospro/identity.go
  • pkg/auth/identities/atmospro/identity_test.go
  • pkg/auth/identities/aws/assume_role_test.go
  • pkg/auth/identities/aws/assume_root_test.go
  • pkg/auth/integrations/github/sts.go
  • pkg/auth/integrations/github/sts_test.go
  • pkg/auth/integrations/types.go
  • pkg/auth/manager.go
  • pkg/auth/manager_environment.go
  • pkg/auth/manager_githubsts_test.go
  • pkg/auth/manager_integrations.go
  • pkg/auth/manager_logout.go
  • pkg/auth/providers/atmospro/provider.go
  • pkg/auth/providers/atmospro/provider_test.go
  • pkg/auth/providers/aws/saml_test.go
  • pkg/auth/types/interfaces.go
  • pkg/auth/types/mock_interfaces.go
  • pkg/auth/types/pro_credentials.go
  • pkg/auth/types/pro_credentials_test.go
  • pkg/config/load.go
  • pkg/downloader/atmos_pro_token_test.go
  • pkg/downloader/custom_git_detector.go
  • pkg/pro/api_client.go
  • pkg/schema/pro.go
  • pkg/schema/schema.go
  • pkg/schema/schema_auth.go
  • website/blog/2026-05-29-atmos-pro-github-sts.mdx
  • website/docs/cli/configuration/auth/identities.mdx
  • website/docs/cli/configuration/auth/index.mdx
  • website/docs/cli/configuration/auth/providers.mdx
  • website/docs/cli/environment-variables.mdx
  • website/src/data/roadmap.js

Comment thread pkg/auth/types/pro_credentials.go Resolved
Add the JIT GitHub token broker packages (pkg/auth/broker,
pkg/auth/providers/atmospro/broker), default manager, and supporting
tests for provisioning the github/sts integration from the ambient CI
environment.

Regenerate the atmos/secrets-masking describe config golden snapshots to
include the new "git_sts" and "AtmosProGithubToken" config fields, fixing
the failing acceptance-test CI jobs on linux/macos/windows.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 30, 2026
@codecov

codecov Bot commented May 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.43198% with 111 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.71%. Comparing base (3023846) to head (41446b3).

Files with missing lines Patch % Lines
pkg/auth/integrations/github/sts.go 85.22% 22 Missing and 21 partials ⚠️
pkg/auth/manager_integrations.go 61.01% 15 Missing and 8 partials ⚠️
pkg/auth/providers/atmospro/provider.go 82.02% 15 Missing and 1 partial ⚠️
internal/exec/terraform_output_utils.go 0.00% 6 Missing ⚠️
pkg/auth/providers/atmospro/broker/broker.go 91.83% 2 Missing and 2 partials ⚠️
pkg/auth/types/pro_credentials.go 87.09% 3 Missing and 1 partial ⚠️
cmd/auth/exec.go 84.21% 3 Missing ⚠️
pkg/auth/broker/broker.go 93.10% 1 Missing and 1 partial ⚠️
pkg/auth/credentials/keyring_file.go 75.00% 1 Missing and 1 partial ⚠️
pkg/auth/credentials/keyring_memory.go 75.00% 1 Missing and 1 partial ⚠️
... and 4 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2546      +/-   ##
==========================================
+ Coverage   78.65%   78.71%   +0.06%     
==========================================
  Files        1184     1191       +7     
  Lines      113107   113772     +665     
==========================================
+ Hits        88962    89561     +599     
- Misses      19258    19288      +30     
- Partials     4887     4923      +36     
Flag Coverage Δ
unittests 78.71% <84.43%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/auth/helpers.go 91.80% <100.00%> (-0.51%) ⬇️
cmd/root.go 68.01% <ø> (ø)
cmd/toolchain/toolchain.go 66.66% <100.00%> (ø)
errors/errors.go 100.00% <ø> (ø)
internal/exec/terraform.go 80.24% <100.00%> (+0.24%) ⬆️
pkg/auth/default_manager.go 100.00% <100.00%> (ø)
pkg/auth/factory/factory.go 93.54% <100.00%> (+0.28%) ⬆️
pkg/auth/identities/atmospro/identity.go 100.00% <100.00%> (ø)
pkg/auth/manager.go 82.93% <ø> (ø)
pkg/auth/types/github_oidc_credentials.go 100.00% <100.00%> (+7.40%) ⬆️
... and 24 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Also fix two latent lint issues surfaced by the new test package:
- shell_utils.go: use errors.As for *exec.ExitError (errorlint).
- sts_test.go: drop always-constant params from stateFilePath helper (unparam).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mergify

mergify Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label May 30, 2026
…thub-token

# Conflicts:
#	internal/exec/shell_utils.go

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
pkg/pro/api_client_pro_sts_test.go (1)

40-44: ⚡ Quick win

Adjust the audience assertion to avoid URL-encoding brittleness

DefaultProAudience is atmos-pro.com (no URL-reserved characters), and the request query is built via q.Encode(), so r.URL.RawQuery should still include audience=atmos-pro.com and the current check won’t fail for the default. If this test ever covers audiences with reserved chars (e.g. https://…), asserting r.URL.Query().Get("audience") == DefaultProAudience would be robust.

🤖 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/pro/api_client_pro_sts_test.go` around lines 40 - 44, Replace the brittle
substring check against r.URL.RawQuery in the httptest server handler with a
query-param equality assertion: read the parsed query via
r.URL.Query().Get("audience") and assert it equals DefaultProAudience so
URL-encoding or reserved characters are handled correctly; update the assertion
in the handler used in the test (the httptest NewTLSServer http.HandlerFunc) to
use r.URL.Query().Get("audience") and DefaultProAudience.
🤖 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.

Nitpick comments:
In `@pkg/pro/api_client_pro_sts_test.go`:
- Around line 40-44: Replace the brittle substring check against r.URL.RawQuery
in the httptest server handler with a query-param equality assertion: read the
parsed query via r.URL.Query().Get("audience") and assert it equals
DefaultProAudience so URL-encoding or reserved characters are handled correctly;
update the assertion in the handler used in the test (the httptest NewTLSServer
http.HandlerFunc) to use r.URL.Query().Get("audience") and DefaultProAudience.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9c84cffb-b073-4407-b3aa-859a3f31141d

📥 Commits

Reviewing files that changed from the base of the PR and between aeeff21 and fae2818.

📒 Files selected for processing (10)
  • cmd/auth/exec_revoke_test.go
  • internal/exec/shell_utils.go
  • pkg/auth/credentials/store_pro_test.go
  • pkg/auth/identities/atmospro/identity_methods_test.go
  • pkg/auth/integrations/github/sts_errors_test.go
  • pkg/auth/integrations/github/sts_test.go
  • pkg/auth/manager_integrations_errors_test.go
  • pkg/auth/providers/atmospro/broker/broker_provision_test.go
  • pkg/auth/providers/atmospro/provider_methods_test.go
  • pkg/pro/api_client_pro_sts_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/auth/integrations/github/sts_test.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 30, 2026
…toolchain token chain

Route atmos.yaml config imports through the canonical go-getter downloader
(downloader.NewGoGetterDownloader) instead of a bare getter.Client, so remote
config imports get the same GitHub authentication as every other remote read:
the CustomGitDetector injects a token into the URL
(ATMOS_PRO_GITHUB_TOKEN > ATMOS_GITHUB_TOKEN > GITHUB_TOKEN) and the Atmos Pro
credential broker exports GIT_CONFIG_* for the spawned git subprocess. Previously
a private-repo import: was fetched unauthenticated.

Thread atmosConfig through ImportAdapter.Resolve, processImports, and
ProcessImportsFromAdapter (all adapters + registry no-op updated).

Prefer ATMOS_PRO_GITHUB_TOKEN in pkg/http GetGitHubTokenFromEnv so the go-github
REST API client and toolchain installs use the same token. Add
ATMOS_PRO_GITHUB_TOKEN to the toolchain --github-token env binding so the viper
key does not shadow it when CI auto-sets GITHUB_TOKEN.

Vendoring and source provisioning already fetch through NewGoGetterDownloader and
are unchanged, preserving their existing per-source retries and timeouts. Config
imports keep their existing 5s timeout (no retry, matching the sibling !include
and remote stack import paths).

Also convert three pre-existing error type switches in pkg/config/load.go to
errors.As (errorlint) so the package passes lint.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mergify

mergify Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label May 30, 2026

@coderabbitai coderabbitai 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.

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 (2)
pkg/config/adapters/gogetter_adapter.go (1)

55-68: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Keep remote-import cancellation wired to the caller context.

GoGetterAdapter.Resolve receives ctx but never uses it; downloadRemoteConfig calls Fetch(..., remoteConfigTimeout) without any context, so cancellation/deadlines won’t stop an in-flight remote fetch until the fixed 5s timeout. (Also affects downloadRemoteConfig at ~108-127.)

Update downloadRemoteConfig (and the downloader path it calls) to accept ctx and derive the timeout from ctx’s deadline, falling back to remoteConfigTimeout only when the caller has no deadline.

🤖 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/config/adapters/gogetter_adapter.go` around lines 55 - 68,
GoGetterAdapter.Resolve currently ignores the passed ctx and calls
downloadRemoteConfig which uses a fixed timeout; update downloadRemoteConfig
signature to accept ctx (e.g., downloadRemoteConfig(ctx context.Context,
importPath, tempDir string, atmosConfig *schema.AtmosConfiguration) ) and change
its downstream downloader call (the Fetch invocation) to derive a timeout from
ctx's deadline (use time.Until if deadline present) and only fall back to
remoteConfigTimeout when no deadline exists; finally, update
GoGetterAdapter.Resolve to pass its ctx into downloadRemoteConfig so
cancellation/deadlines from the caller propagate.
pkg/config/import_test_helpers_test.go (1)

24-32: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Preserve atmosConfig through the helper’s recursive path.

This helper accepts the new parameter, then drops it and always recurses with nil. That means the nested-import tests can’t catch regressions in the auth/config propagation this PR adds.

Suggested fix.
 func (l *testLocalAdapter) Resolve(
 	_ context.Context,
 	importPath string,
 	basePath string,
 	tempDir string,
 	currentDepth int,
 	maxDepth int,
-	_ *schema.AtmosConfiguration,
+	atmosConfig *schema.AtmosConfiguration,
 ) ([]ResolvedPaths, error) {
@@
 		// Recursively process nested imports.
 		if len(imports) > 0 {
-			nestedPaths, err := ProcessImportsFromAdapter(nil, importBasePath, imports, tempDir, currentDepth+1, maxDepth)
+			nestedPaths, err := ProcessImportsFromAdapter(atmosConfig, importBasePath, imports, tempDir, currentDepth+1, maxDepth)
 			if err != nil {
 				log.Debug("failed to process nested imports from", "path", path, "error", err)
 				continue
 			}

As per coding guidelines, **/*_test.go: Every new feature must include comprehensive unit tests targeting >80% code coverage for all packages.

Also applies to: 85-88

🤖 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/config/import_test_helpers_test.go` around lines 24 - 32, The
testLocalAdapter.Resolve helper accepts an atmosConfig parameter but drops it on
recursive calls (passing nil), which breaks propagation of auth/config to nested
imports; update testLocalAdapter.Resolve so any recursive invocation (the call
that currently passes nil) forwards the received atmosConfig instead of nil,
ensuring the atmosConfig is preserved through recursion and nested-import tests
can validate auth/config propagation; adjust any associated helper invocations
in Resolve to use the atmosConfig variable.
🧹 Nitpick comments (1)
pkg/http/client_test.go (1)

589-643: ⚡ Quick win

Cover the flag-over-env case with ATMOS_PRO_GITHUB_TOKEN too.

This table only proves the raw env fallback order. Since ATMOS_PRO_GITHUB_TOKEN is now the highest env source, please add a case where viper has "github-token" set and ATMOS_PRO_GITHUB_TOKEN is also populated, so we keep guarding the CLI flag precedence contract.

🤖 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/http/client_test.go` around lines 589 - 643, Add a test case inside
TestGetGitHubTokenFromEnv_AtmosProPrecedence that verifies flag/cli precedence:
create a subtest where you set viper with the "github-token" key (e.g., v :=
viper.New(); v.Set("github-token", "flag-token")) and also set the
ATMOS_PRO_GITHUB_TOKEN env var to a different value, then call
GetGitHubTokenFromEnv(v) and assert the result equals the viper value
("flag-token"); this ensures the function respects the viper/flag precedence
over the new ATMOS_PRO_GITHUB_TOKEN env fallback.
🤖 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 `@pkg/config/adapters/adapters_test.go`:
- Line 451: The test currently passes a hardcoded Unix-only path
"/nonexistent/temp/dir" to adapter.Resolve; replace that with a child path built
under the test's temporary directory so the missing-path behavior is portable.
Construct the path using t.TempDir() and filepath.Join (e.g.,
filepath.Join(t.TempDir(), "nonexistent", "temp", "dir")) but do not create the
directory so adapter.Resolve still fails; update the test call to
adapter.Resolve(ctx, "mock://test", missingPath, "/base", 1, 10, nil) and ensure
the test imports and uses filepath.Join and t.TempDir() instead of the hardcoded
literal.

---

Outside diff comments:
In `@pkg/config/adapters/gogetter_adapter.go`:
- Around line 55-68: GoGetterAdapter.Resolve currently ignores the passed ctx
and calls downloadRemoteConfig which uses a fixed timeout; update
downloadRemoteConfig signature to accept ctx (e.g., downloadRemoteConfig(ctx
context.Context, importPath, tempDir string, atmosConfig
*schema.AtmosConfiguration) ) and change its downstream downloader call (the
Fetch invocation) to derive a timeout from ctx's deadline (use time.Until if
deadline present) and only fall back to remoteConfigTimeout when no deadline
exists; finally, update GoGetterAdapter.Resolve to pass its ctx into
downloadRemoteConfig so cancellation/deadlines from the caller propagate.

In `@pkg/config/import_test_helpers_test.go`:
- Around line 24-32: The testLocalAdapter.Resolve helper accepts an atmosConfig
parameter but drops it on recursive calls (passing nil), which breaks
propagation of auth/config to nested imports; update testLocalAdapter.Resolve so
any recursive invocation (the call that currently passes nil) forwards the
received atmosConfig instead of nil, ensuring the atmosConfig is preserved
through recursion and nested-import tests can validate auth/config propagation;
adjust any associated helper invocations in Resolve to use the atmosConfig
variable.

---

Nitpick comments:
In `@pkg/http/client_test.go`:
- Around line 589-643: Add a test case inside
TestGetGitHubTokenFromEnv_AtmosProPrecedence that verifies flag/cli precedence:
create a subtest where you set viper with the "github-token" key (e.g., v :=
viper.New(); v.Set("github-token", "flag-token")) and also set the
ATMOS_PRO_GITHUB_TOKEN env var to a different value, then call
GetGitHubTokenFromEnv(v) and assert the result equals the viper value
("flag-token"); this ensures the function respects the viper/flag precedence
over the new ATMOS_PRO_GITHUB_TOKEN env fallback.
🪄 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: 7a00c8b9-0261-4520-b84b-d316dd9014fc

📥 Commits

Reviewing files that changed from the base of the PR and between 05a4884 and 8fe5fd0.

📒 Files selected for processing (15)
  • cmd/toolchain/toolchain.go
  • pkg/config/adapters/adapters_test.go
  • pkg/config/adapters/gogetter_adapter.go
  • pkg/config/adapters/local_adapter.go
  • pkg/config/adapters/mock_adapter.go
  • pkg/config/import_adapter.go
  • pkg/config/import_adapter_registry.go
  • pkg/config/import_adapter_registry_test.go
  • pkg/config/import_test.go
  • pkg/config/import_test_helpers_test.go
  • pkg/config/imports.go
  • pkg/config/imports_error_paths_test.go
  • pkg/config/load.go
  • pkg/http/client.go
  • pkg/http/client_test.go

Comment thread pkg/config/adapters/adapters_test.go Resolved
…thub-token

# Conflicts:
#	pkg/config/load.go
Replace the hardcoded Unix-only paths with a missing child path under
t.TempDir() (left uncreated) so the write-failure case is exercised
identically on Linux/macOS/Windows. The failure is driven by the tempDir
argument (where MockAdapter.writeConfig writes), so the missing path is
passed there. Addresses CodeRabbit review feedback.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…S parity)

Export the raw minted GitHub token under a named env var (literal or
{owner} placeholder) so non-git consumers (gh, actions/checkout, REST API)
can use it, mirroring the Octo-STS action. Adds schema field, env/file-mode
wiring, owner sanitization, tests, PRD, blog, and docs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
www.anthropic.com/claude-code now 301-redirects to claude.com/product/
claude-code, whose edge returns HTTP 500 to non-browser/CI requests
(bot-blocking), failing the Check Markdown Links job. Point the link at
the canonical claude.com URL and exclude claude.com/product/ in
lychee.toml, mirroring the existing exclusions for domains that block CI
requests. The code.claude.com docs subdomain stays checked.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@aknysh
Andriy Knysh (aknysh) merged commit 732bcfb into main Jun 1, 2026
95 of 96 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/atmos-pro-github-token branch June 1, 2026 18:12
@atmos-pro

atmos-pro Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

These changes were released in v1.221.0-rc.2.

Andriy Knysh (aknysh) added a commit that referenced this pull request Jun 2, 2026
#2557)

* fix(auth): make github/sts compose with default GitHub token injection

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]>

* docs(auth): clarify ATMOS_PRO_GITHUB_TOKEN default is single-owner only

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]>

* [autocommit] formatting fixes

* fix(notice): make license URLs deterministic for vanity-path modules

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]>

* docs(auth): remove Octo-STS comparison from product surface

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]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
Co-authored-by: atmos-pro[bot] <173522224+atmos-pro[bot]@users.noreply.github.com>
Co-authored-by: Andriy Knysh <[email protected]>

This branch was successfully deployed

1 active deployment
preview — 41446b3a Deployed Jun 1, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants