feat(auth): Add --save-to-file flag for explicit credential file fallback #654
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 addresses issue #643 by adding an explicit
--save-to-fileflag that allows users to save credentials to a file when the system keyring is unavailable.This PR replaces #653 with a more secure approach that requires explicit user consent for fallback to file storage.
Problem (Issue #643)
Users on WSL, ARM systems, and headless environments encounter keyring errors:
Currently, there's no fallback mechanism, forcing the user to use environment variable UPCLOUD_TOKEN and failing to save token on login.
Solution
--save-to-fileflag toaccount logincommand~/.config/upcloud/credentialswith 0600 permissions--save-to-fileoptionChanges
internal/config/credentials_file.go- Handles credential file operationsinternal/commands/account/login.go- Added--save-to-fileflaginternal/config/config.go- Load from credentials file before attempting keyringinternal/clierrors/missing_credentials.go- error messages with fallback guidanceSecurity Considerations
--save-to-fileflagUser Experience
Successful save with --save-to-file:
Keyring failure without flag:
Related