-
Notifications
You must be signed in to change notification settings - Fork 237
[CALCITE-6135] BEARER authentication support #299
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
|
This is the rebase and clean up version of #232 |
f869d41 to
069d250
Compare
|
|
||
| void init(ConnectionConfig config) throws IOException; | ||
|
|
||
| String obtain(String username); |
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.
Can you please document this method?
What is the result?
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.
Sure, I'll do that
It returns the Token used for Authentication.
| if (null == username) { | ||
| username = System.getProperty("user.name"); | ||
| } | ||
| ((BearerAuthenticateable) client).setTokenProvider(username, tokenProvider); |
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.
can userName by null here?
The method that follows does not expect them.
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.
The userName can not be null when calling setTokenProvider
We need it later when we get the JWT token:
new BearerToken(tokenProvider.obtain(username))
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.
But can't System.getProperty return null?
| /** Bearer token to use to perform Bearer authentication. */ | ||
| BEARER_TOKEN("bearer_token", Type.STRING, null, false), | ||
|
|
||
| /** File containing bearer tokens to use to perform Bearer authentication. */ |
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.
Not obvious how the file is represented using a string, presumably it's some kind of path or URI.
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.
Yes, a path
With this I would like to add the possibility to add an other implementation for BearerTokenProvider In the future.
Where instead of storing the Token, we can store the token file's location and load the token(s) from a file.
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.
Can you please add this information to JavaDoc?
| int getInt(); | ||
|
|
||
| /** | ||
| * Returns the int value of this property. Throws if not set and no |
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.
No default means defaultValue is null?
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.
Probably You are right it can only happen if the defaultValue is set to null
| String getString(String defaultValue); | ||
|
|
||
| /** | ||
| * Returns the int value of this property. Throws if not set and no |
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.
What does "default" mean here?
Is this a per-property notion?
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.
It has been copied from PropEnv, the same applies to all similar functions.
Should I remove the trows if not set and no default part?
Do you think a comment like this would be better?
Returns the long value of this property or the defaultValue.
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.
Well, it's not "long"
And I still don't know where the default value is coming from.
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.
property is a ConnectionProperty which has a defaultValue functions.
| * Returns the string value of this property, or null if not specified and | ||
| * no default. | ||
| */ | ||
| String getString(String defaultValue); |
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.
this is the only one that never throws, why this asymmetry?
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.
I think either getString methods Throw.
It has been copied from PropEnv which is the implementation of this ConnectionPropertyValue interface
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.
I know you didn't write that documentation, but is there a way to check whether this is correct?
If not, maybe you can fix it there too.
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| public class BearerTokenProviderFactoryTest { |
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.
are all tests in this file negative?
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.
Can you please be more specific?
In testCustomBearerToken and testConstantBearerToken I test the happy path to validate the correct behavior of tokenProvider.obtain.
There is message property provided if the expected value is different from the actual.
069d250 to
c461b58
Compare
|
Please avoid force-pushing until the review is finished; it makes it harder to see what is changed. |
mihaibudiu
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.
Now you can squash the commits for merging.
Co-authored-by: Aron Meszaros <[email protected]>
380825e to
414f6d9
Compare
|
Thank you @mihaibudiu for the review I squashed the change to 1 commit. Please merge it when you have time. |
No description provided.