Add secure API key management via ccr config command #643
+349
−7
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.
Fixes #642
Summary
Implements secure credential storage for API keys, eliminating the need for environment variables or hardcoded keys in config.json.
Implementation Details
New
ccr config
Commandccr config set <provider>
- Store API key (supports interactive and piped input)ccr config get <provider>
- Check if key is configured (never shows full key)ccr config list
- List all configured providers with masked keysccr config delete <provider>
- Remove stored API keyStorage Approach
~/.claude-code-router/keys
as JSONIntegration
interpolateEnvVars
to check keystore first, then environment variablesArchitecture
KeyStore
interface for future extensibilityFileKeyStore
using filesystem with strict permissionsNativeKeyStore
for OS keychains (macOS Keychain, Windows Credential Manager, Linux Secret Service)Testing
Security Considerations
Migration Path
Next Steps
Future PR will add optional native OS keychain support via @napi-rs/keyring for users who want additional security beyond filesystem permissions.