Store credentials in system keychain by default#289
Conversation
b8d373c to
a4d446b
Compare
Add keychain-backed credential storage via go-keyring (com.circleci.cli service). Credentials are saved to the system keychain by default and fall back to the config file when the keychain is unavailable. The --insecure-storage flag on chunk auth set opts into plaintext file storage. CircleCI tokens are keyed by host so different instances stay separate. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a4d446b to
f40c742
Compare
| } | ||
|
|
||
| // auth status reads key from config file when no env var is set | ||
| func TestAuthStatusFromConfigFile(t *testing.T) { |
There was a problem hiding this comment.
Happy to revert these if people think the fallback resolution tests are of dire importance. But a) we want to ditch config file as even an option and b) the keychain dep is harder to test and the code around it is simple.
e07610f to
17c448f
Compare
…ests Tests that resolved credentials from config file are removed — env var coverage is sufficient. isolateConfig and setupTempConfig now set dummy credential env vars so Resolve() never falls through to the system keychain during local test runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
17c448f to
991b238
Compare
Resolves conflicts in auth.go, go.mod, and acceptance/auth_test.go. Combines --insecure-storage (keychain fallback) with --force/-f flag and non-interactive handling from main. Updates docs to reflect both new flags and keychain-first storage behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Verifies all four goreleaser targets (linux/amd64, linux/arm64, darwin/amd64, darwin/arm64) build cleanly with CGO_ENABLED=0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Matches how goreleaser actually builds the binary and ensures the smoke test catches any CGO dependency introduced accidentally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude:
if err := keyring.Set(keyring.CircleCITokenKey(baseURL), token); err == nil {
In auth.go:595: if rc.CircleCIToken != "" && !envSet { |
When insecureStorage is false (the default), a keychain write failure now returns an error rather than transparently saving to the plaintext config file. Users on systems without a working keychain must pass --insecure-storage explicitly. Adds keyring.MockInit() so tests that exercise keychain code paths can use an in-memory backend without touching the real system keychain. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the review Scott!
|
Adds a warning in printSaved when --insecure-storage is used, and in auth status for each credential that comes from the config file, with a suggestion to re-run 'chunk auth set' to migrate to the keychain. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
180a8ee to
a47faa2
Compare
…nt wording - auth remove now checks both keychain and config file for stored credentials instead of only the config file, so keychain-stored tokens are actually cleared - Resolve() returns early if config.Load() fails rather than proceeding with a zero-value UserConfig and making unnecessary keychain calls - printSaved warning now says 'chunk auth set <provider>' (runnable command) - TestAuthRemoveWithStoredKey verifies config file via os.ReadFile instead of config.Load() to avoid coupling acceptance test to internal resolution logic Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Stores credentials (CircleCI token, Anthropic API key, GitHub token) in the system keychain by default instead of the plaintext config file.
Migration
Existing users with credentials in the config file continue to work — credentials are still read from both sources. `chunk auth status` will show a warning and prompt them to re-run `chunk auth set` to move credentials to the keychain.
Test plan