fix(cli): skip saved session lookup for machine auth - #399
Closed
nikhilmaddirala wants to merge 2 commits into
Closed
nikhilmaddirala wants to merge 2 commits into
nikhilmaddirala wants to merge 2 commits into
Conversation
📝 Contributor License Agreement requiredBefore this PR can merge, every contributor must sign the Infisical CLA. Commits from unrecognized email addresses (not linked to a GitHub account):
Please link this email to your GitHub account and push again, or sign with the account that owns it. Once everyone has signed, the check updates automatically — no need to close and reopen the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The root command checked the saved user session before detecting a supplied machine token or explicit Universal Auth login credentials. That made commands that do not need a saved session read the platform credential store.
This change skips that lookup for:
INFISICAL_TOKENlogin --method universal-authwith explicit client credentials from flags or environment variables--silentinvocations, where the optional warning is suppressedThe optional saved-session overwrite warning is intentionally skipped for these
machine-authenticated paths. Showing it would require reading the platform
credential store, even though the command does not need a saved user session.
Non-machine, non-silent commands retain the existing root pre-run lookup.
Validation
nix shell nixpkgs#go --command go test -vet=off ./packages/cmd -run 'Test(ShouldReadSavedSession|HasExplicitUniversalAuthCredentials|RootPersistentPreRunSavedSessionLookup)$' -count=1nix shell nixpkgs#go --command go test -vet=off ./packages/cmd -count=1nix shell nixpkgs#go --command go build -o /tmp/infisical-cli-session-check .git diff --checkThe hook-level test invokes the root
PersistentPreRunwithINFISICAL_TOKEN, Universal Auth flags, and Universal Auth environment credentials. It uses an injected saved-session lookup and asserts those paths never call it, without accessing Secret Service, Keychain, or any other platform credential store.With the locally available Go 1.26.7, the same package test without
-vet=offstops on existingzerolog.Event.Msgfnon-constant-format diagnostics inpackages/cmd/run.go, before the new tests run.Agent Attribution
codex-gpt-5-developercodexgpt-5developervermax/home/nikhilmaddirala/.codex/worktrees/infisical-cli-token-bypassauthor-onlynikhilmaddirala