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

GH-445: [Flight] Add middleware for auth2 bearer tokens #503

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

Conversation

devinrsmith
Copy link
Contributor

Rationale for this change

This makes it easier to work with auth2 from the Java client without needing to resort to ClientCookieMiddleware (ie, don't need to force the server to support a non-standard auth scheme). I think it could be highly beneficial for ease-of-use when directly creating a FlightClient, and I would expect that the various FlightSqlClient drivers (ADBC, JDBC) could benefit from supporting it as a configuration option.

What changes are included in this PR?

A new FlightClientMiddleware had been added.

Are these changes tested?

These changes have been manually tested; if more testing is necessary, I'm hoping another contributor can provide it or guide me through a test plan.

Note: this is a re-creation of #446, I think some codeowner logic was not in place when I originally created the PR.

Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

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

I think this might be useful, but we probably need to sit down and sort out all the existing auth options...there are too many at this point and it's unclear how each of them work without having to go read every implementation (I think this PR does not overlap with any of them, but it's hard to make sure)

I think this needs at least a basic test using an in-process server. For instance the server could track the last token it received, and the test could assert that the client and the server see the 'correct' token as it is changed (on either side).


public static class Factory implements FlightClientMiddleware.Factory {

private volatile String bearerValue;
Copy link
Member

Choose a reason for hiding this comment

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

I think AtomicReference would be more appropriate here

}

void setBearerValue(String bearerValue) {
// Avoid volatile write if the value hasn't changed
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this optimization introduce a TOC/TOU error?

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