Feature Request: Secure Token Storage in OS Keyring
Problem
Currently, the Coder CLI stores authentication tokens in plaintext configuration files, which poses a security risk. Users' tokens are stored unencrypted and can be easily accessed by other processes or users with file system access.
Proposed Solution
Implement secure token storage using the OS keyring with graceful fallback to file storage when keyring is unavailable.
Acceptance Criteria
Implementation Considerations
- Library Choice: Use
zalando/go-keyring for pure Go implementation without CGO requirements
- Migration: Handle existing plaintext tokens gracefully during the transition
- Error Handling: Robust fallback mechanism when keyring operations fail
- Cross-platform: Ensure consistent behavior across macOS, Linux, and Windows
- User Experience: Minimal prompts and clear messaging about keyring access
- Testing: Comprehensive tests for both keyring and fallback scenarios
Security Benefits
- Tokens encrypted at rest using OS-provided security mechanisms
- Reduced risk of accidental token exposure in config files
- Better integration with enterprise security policies
References
Feature Request: Secure Token Storage in OS Keyring
Problem
Currently, the Coder CLI stores authentication tokens in plaintext configuration files, which poses a security risk. Users' tokens are stored unencrypted and can be easily accessed by other processes or users with file system access.
Proposed Solution
Implement secure token storage using the OS keyring with graceful fallback to file storage when keyring is unavailable.
Acceptance Criteria
CLI should by default store the token in the OS keyring using a library like zalando/go-keyring
CLI should fallback to storing the token in text file if the keyring is not available
Address security considerations from GitHub CLI's keyring implementation discussion:
zalando/go-keyringwhich shells out to thesecuritycommand on macOSsecuritybinary rather than the specific application, which can weaken the security modelImplementation Considerations
zalando/go-keyringfor pure Go implementation without CGO requirementsSecurity Benefits
References