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

allow for externally managed token files #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jmozd
Copy link
Contributor

@jmozd jmozd commented Jun 23, 2021

It may be preferrable to have an external mechanism manage the OAuth2
tokens, rather than having the sasl-xoauth2 plug-in do this for you.

To allow for this scenario, a new config parameter "external_token_manager"
was introduced. When set to true, sasl-xauth2 will use the "password" field
content as the name of a file that contains the current OAuth2 token for the
user. No other configuration is needed for this plug-in, but an external
mechanism must be in place to keep the content of that token file current
at all times.

It may be preferrable to have an external mechanism manage the OAuth2
tokens, rather than having the sasl-xoauth2 plug-in do this for you.

To allow for this scenario, a new config parameter "external_token_manager"
was introduced. When set to true, sasl-xauth2 will use the "password" field
content as the name of a file that contains the current OAuth2 token for
user. No other configuration is needed for this plug-in, but an external
mechanism must be in place to keep the content of that token file current
at all times.
Copy link
Owner

@tarickb tarickb left a comment

Choose a reason for hiding this comment

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

Sorry it took me so long to get to this -- I somehow managed to miss the pull request.

@@ -29,6 +29,7 @@ class Config {

static Config *Get();

bool external_token_manager() const { return external_token_manager_; }
Copy link
Owner

Choose a reason for hiding this comment

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

Can we call this "manage_token_externally"?

@@ -1,4 +1,5 @@
{
"external_token_manager": "no",
Copy link
Owner

Choose a reason for hiding this comment

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

I'd prefer to leave this out of the sample config file, since I imagine most users won't need it and I'd like to avoid the confusion.

if (!token_) return SASL_FAIL;
} else {
tokenfile_ = password;
}
Copy link
Owner

Choose a reason for hiding this comment

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

I think it's cleaner overall if instead of having two different code paths here, in Client, we push this complexity into TokenStore by adding a flag there that just disables refreshes. Client would remain unmodified except that it passes the value of manage_token_externally to TokenStore, and TokenStore would just always return whatever's in the token file, regardless of the expiry time.

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.

None yet

2 participants