feat: add encrypted credential store for headless Linux environments - #22
Merged
Merged
Conversation
When Linux Secret Service is unavailable (no D-Bus session or secret-tool missing), auth login now falls back to an encrypted local file store instead of failing with CREDENTIAL_STORE_UNAVAILABLE. Changes: - Add linux-encrypted-file backend using AES-256-GCM encryption - Use PBKDF2 (600k iterations) to derive keys from master password - Store encrypted credentials at ~/.config/sustech-cli/encrypted-credentials/ - Maintain existing Secret Service preference when available - Never store passwords in plaintext - Add tests for encrypted store operations - Update docs to reflect new headless Linux credential path Fixes headless servers, containers, and CI environments where desktop Secret Service is unavailable but persistent auth is still needed.
Add interactive master password prompting and SUSTECH_MASTER_PASSWORD environment variable support for the encrypted credential store. Changes: - Add promptMasterPassword() function for secure password input - Update auth login to prompt for master password when needed - Support SUSTECH_MASTER_PASSWORD env var for non-interactive use - Update resolveCredentials to pass master password to keyring - Add documentation for master password usage patterns - All 468 tests pass
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
This PR enables
sustech auth loginto persist CAS credentials on Linux environments that do not have a usable desktop Secret Service (headless servers, containers, coding-agent boxes). Previously these hosts would fail withCREDENTIAL_STORE_UNAVAILABLE.Problem
Current Linux credential storage strictly requires:
DBUS_SESSION_BUS_ADDRESS)secret-toolexecutable fromlibsecret-toolsHeadless Linux hosts (containers, CI environments, remote servers) typically lack these requirements, forcing users to:
SUSTECH_SID/SUSTECH_PASSWORDfor every process--credentials-fileSolution
When Linux Secret Service is unavailable, the CLI now automatically falls back to a new encrypted local file store (
linux-encrypted-filebackend):Technical details
~/.config/sustech-cli/encrypted-credentials/(file mode0600)Behavior
SUSTECH_MASTER_PASSWORDenv varUsage examples
Changes
Core implementation
src/core/encrypted-store.ts: New encrypted store implementationsrc/core/keyring.ts: Updated to fall back to encrypted store when Secret Service unavailablelinux-encrypted-filebackend typeresolveLinuxSecretService()to fall back gracefullyresolveLinuxEncryptedFile()functionsrc/core/prompt.ts: AddedpromptMasterPassword()for secure inputsrc/cli.ts: Updatedauth loginto prompt for master password when neededsrc/core/credentials.ts: Updated to pass master password to keyringTesting
src/test/encrypted-store.test.ts: Unit tests for encrypted store operationssrc/test/keyring.test.ts: Integration tests for Linux fallback behaviorDocumentation
docs/AUTHENTICATION.md: Updated platform backends table and added encrypted store details with usage examplesdocs/ARCHITECTURE.md: Updated to reflect new credential storage strategyCHANGELOG.md: Added release notes for this featureMigration & backwards compatibility
SUSTECH_SID/SUSTECH_PASSWORDand--credentials-fileremain valid overridesSecurity considerations
What's protected
0600(owner read/write only)SUSTECH_MASTER_PASSWORDenvironment variable (non-interactive use)What's NOT protected against
Comparison to plaintext
This is significantly better than:
--credentials-file(no encryption)Comparison to Secret Service
Secret Service is still preferred when available because:
Testing performed
0600)Checklist
Related
Addresses the real-world pain point where agent/CI boxes have Node but no gnome-keyring/Secret Service, yet users want
auth loginonce and then usebb/tiscommands without re-injecting env vars every shell.