Skip to content
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

REC-110: don't use keyring when an unencrypted file token is present #60

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

jayconrod
Copy link
Contributor

On Linux, the keyring library can prompt the user for a password if it's not automatically unlocked. This causes engflow_auth to hang when invoked as a credential helper because neither stdin nor stdout are connected to a terminal.

With this change, the get command (and anything else that calls loadToken) now checks for a token created with -store=file first, then falls back to the keyring library if that's not present. This reverses the previous order.

When storing a token into the keyring, storeToken now deletes the token created with -store=file, if present, preventing it from taking precedence.

Together, these changes that mean when -store=file is used, the keyring library should only be used by the logout command, which attempts to delete both tokens.

@@ -28,6 +28,7 @@ import (
type FakeTokenStore struct {
Tokens map[string]*oauth2.Token
LoadErr, StoreErr, DeleteErr error
PanicValue any
Copy link
Contributor

@rogerhu rogerhu Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Edit: I see it. Any reason it's an any type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments.

For added context that shouldn't be in the fake: the real version can hang indefinitely, so I wanted to test that it's not called. I'd rather not simulate the hang-forever behavior in a test, so it seemed better to panic loudly.

panic accepts an any rather than an error, so that's the value I used. any is a builtin type alias for interface{}.

Base automatically changed from jay-2-fallback to main November 27, 2024 16:00
On Linux, the keyring library can prompt the user for a password if
it's not automatically unlocked. This causes engflow_auth to hang
when invoked as a credential helper because neither stdin nor stdout
are connected to a terminal.

With this change, the get command (and anything else that calls loadToken)
now checks for a token created with -store=file first, then falls back
to the keyring library if that's not present. This reverses the previous
order.

When storing a token into the keyring, storeToken now deletes the token
created with -store=file, if present, preventing it from taking precedence.

Together, these changes that mean when -store=file is used, the keyring
library should only be used by the logout command, which attempts to
delete both tokens.
@jayconrod jayconrod merged commit 8ed260b into main Nov 27, 2024
5 checks passed
@jayconrod jayconrod deleted the jay-3-skip-keyring branch November 27, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants