-
Notifications
You must be signed in to change notification settings - Fork 48
SUP-5203: use keychain for api token #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ben McNicholl <[email protected]>
Signed-off-by: Ben McNicholl <[email protected]>
JoeColeman95
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Only thing is I'd put something about the keychain org list limitation in the heredoc somewhere
|
Some folks use the CLI in CI pipelines, so we definitely want to mention that as a breaking chance, since keyring would be the default now. |
|
@scadu it should be falling back to the config if the token is not present in keychain |
| // APIToken gets the API token configured for the currently selected organization | ||
| // Priority order: BUILDKITE_API_TOKEN env var → keychain → config file (legacy) | ||
| func (conf *Config) APIToken() string { | ||
| // Environment variable takes precedence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scadu this section should be what you're after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcncl ah, thanks for pointing that! Nice!
|
@JoeColeman95 good point; I'll work on a fix; storing orgs as keys with empty values in the config file so the list of user orgs is still present and can be used as a look up against Keychain |
Description
Currently we store API tokens in plain text in a config file in the user's
.configdirectory, that's not ideal.Changes
This change moves to using keychain (or Linux/Windows variants) for API tokens by default, but users can override this by setting the token source as
fileusing an environment variable.We've implemented the following;
bk configure addstill prompts as normal, but on storing the API token we use theorganizationas the identifier within keychainbk configure migratecommand to move existing tokens and their organization to keychain~/.config/bk.yamlfile entirely