feat(cli)!: encrypt keyring-mode tokens to file#49
Merged
Conversation
- Switch keyring token store to an encrypted file backend, keeping only the master key in the OS keyring - Avoid keyring blob size limits for large tokens such as those carrying groups claims - Update token storage docs to describe the encrypted file behavior - Bump go-authgate/sdk-go and other dependencies BREAKING CHANGE: keyring mode now writes AES-256-GCM-encrypted tokens to TOKEN_FILE.enc instead of storing the whole token in the OS keyring. Tokens previously saved in keyring mode are not migrated, so users must re-authenticate once after upgrading.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Switches the
keyringtoken-store mode from storing the entire token in the OS keyring to an encrypted file backend: only a 32-byte master key stays in the keyring, while the token is AES-256-GCM-encrypted toTOKEN_FILE.enc. This avoids keyring blob size limits (e.g. the Windows Credential Manager 2560-byte cap) that large tokens — such as those carryinggroupsclaims — can hit. Also bumpsgo-authgate/sdk-goto v0.13.0 (which providesNewTokenEncryptedFileStore) and other dependencies.Architecture / flow
flowchart TD M["--token-store / TOKEN_STORE"] --> SW{"newTokenStore(mode)"} SW -->|file| F["NewTokenFileStore<br/>plaintext TOKEN_FILE"] SW -->|auto| A["DefaultTokenSecureStore<br/>keyring key + TOKEN_FILE.enc,<br/>plaintext fallback"] SW -->|keyring| K["NewTokenEncryptedFileStore<br/>keyring key + TOKEN_FILE.enc"] K --> KR["OS keyring<br/>(32-byte master key)"] K --> ENC["TOKEN_FILE.enc<br/>(AES-256-GCM, 0600)"] style K fill:#dff0d8,stroke:#3c763d style KR fill:#dff0d8,stroke:#3c763d style ENC fill:#dff0d8,stroke:#3c763dAI Authorship
config.go(thekeyringbranch + doc comment),config_test.go,README.md, dependency bumps ingo.mod/go.sumChange classification
Verification
TestNewTokenStoreupdated to assertkeyringmode returns*credstore.EncryptedFileStore[credstore.Token]golangci-lintreports 0 issues;/security-reviewfound no high-confidence findings--token-store keyring, authenticate, confirmTOKEN_FILE.encis written0600andtoken getreads it backRisk & rollback
keyringmode live in the OS keyring and are not migrated; users must re-authenticate once after upgrading.keyringmode now also writes a file (TOKEN_FILE.enc) instead of being file-free.NewTokenKeyringStore, so the prior behavior is restored on revert.Reviewer guide
config.gonewTokenStore— thekeyringcase and thetokenFilePath+".enc"path derivation (note it intentionally shares the.encpath withautomode so tokens are cross-readable)config_test.go,README.md,go.mod/go.sum🤖 Generated with Claude Code