[CALCITE-6135] BEARER authentication support#299
[CALCITE-6135] BEARER authentication support#299richardantal wants to merge 2 commits intoapache:mainfrom
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.
Can you please document this method?
What is the result?
There was a problem hiding this comment.
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.
can userName by null here?
The method that follows does not expect them.
There was a problem hiding this comment.
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.
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.
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.
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.
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.
No default means defaultValue is null?
There was a problem hiding this comment.
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.
What does "default" mean here?
Is this a per-property notion?
There was a problem hiding this comment.
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.
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.
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.
this is the only one that never throws, why this asymmetry?
There was a problem hiding this comment.
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.
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.
are all tests in this file negative?
There was a problem hiding this comment.
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.
Co-authored-by: Aron Meszaros <meszaros.aron.attila@gmail.com>
069d250 to
c461b58
Compare
|
Please avoid force-pushing until the review is finished; it makes it harder to see what is changed. |
BearerToken edge case handling, user is null, bearer token is null more tests added for tokenProvider and setTokenProvider
mihaibudiu
left a comment
There was a problem hiding this comment.
Now you can squash the commits for merging.
No description provided.