Uh oh!
There was an error while loading. Please reload this page.
[PLUGIN-692] Add Service Account auth to http - #80
Conversation
…od into radio buttons.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| * @return The AuthType | ||
| */ | ||
| public static AuthType fromValue(String value) { | ||
| return Arrays.stream(AuthType.values()).filter(authtype -> authtype.getValue().equals(value)) |
There was a problem hiding this comment.
I copied this file from the google drive plugin. I didn't really look at it into details
| GoogleCredentials credential; | ||
| String jwtToken = ""; | ||
| if (config.isServiceAccountJson()) { | ||
| InputStream jsonInputStream = new ByteArrayInputStream(config.getServiceAccountJson().getBytes()); |
There was a problem hiding this comment.
Ensure you pass UTF-8 otherwise it's current encoding-dependent. Also it's a good habit to put any InputStreams into try with resources block to ensure it's closed.
There was a problem hiding this comment.
The function itself throws IOException so I did not add the try block
| if (config.isServiceAccountJson()) { | ||
| InputStream jsonInputStream = new ByteArrayInputStream(config.getServiceAccountJson().getBytes()); | ||
| credential = GoogleCredentials.fromStream(jsonInputStream); | ||
| jwtToken = generateJwt(5000, credential); |
There was a problem hiding this comment.
How did you decide on 5 seconds? Also it's better to have it at least as a constant as it makes code more readable
There was a problem hiding this comment.
This is 5000 seconds based on the documentation. I'm not sure what time range I should choose
There was a problem hiding this comment.
Oh, I see, you convert it to millis. 5000 seconds is probably fine, but please make a constant that clearly says it's seconds in it's name
There was a problem hiding this comment.
Also 5000 seconds is an odd time. I would expect it to be aligned to an hour (3600 seconds) or a day (86400 seconds).
I also think this value should be in a configuration option for the user to configure. Some users might not feel comfortable with long living JWT tokens.
| <common.codec.version>1.12</common.codec.version> | ||
| <gson.version>2.8.5</gson.version> | ||
| <googleauth.version>1.6.0</googleauth.version> | ||
| <guava.version>31.1-jre</guava.version> |
There was a problem hiding this comment.
I'd try to use guava version from hydrator. Otherwise strange things may happen
There was a problem hiding this comment.
And BTW, where are you using it? I don't see guava references in the source
There was a problem hiding this comment.
The GoogleCredentials is asking for one of the package from guava. It won't let me build before I include it.
There was a problem hiding this comment.
Hm. Why don't they include it themselves? Usually it's up to an artifact to include any dependency needed
| * @return The AuthType | ||
| */ | ||
| public static AuthType fromValue(String value) { | ||
| return Arrays.stream(AuthType.values()).filter(authtype -> authtype.getValue().equals(value)) |
| public static String getAccessTokenByServiceAccount(BaseHttpSourceConfig config) throws IOException { | ||
| GoogleCredentials credential; | ||
| Integer expiryLength = (config.getJwtTokenExpiryLength() != null) ? config.getJwtTokenExpiryLength() : 3600; |
There was a problem hiding this comment.
The reason I use Integer is because it can be compared with null. I can't do that with int
There was a problem hiding this comment.
I understand for config, but I don't think you need to do it for expiryLength var
[PLUGIN-692] Add Service Account auth to http
Description
Added Service Account auth to http batch source. Currently the unit tests won't pass
Links
PLUGIN-692
Screenshots