-
Notifications
You must be signed in to change notification settings - Fork 105
Conversation
Codecov Report
@@ Coverage Diff @@
## master #504 +/- ##
============================================
- Coverage 72.53% 72.46% -0.07%
- Complexity 859 863 +4
============================================
Files 170 170
Lines 3462 3929 +467
Branches 277 305 +28
============================================
+ Hits 2511 2847 +336
- Misses 808 938 +130
- Partials 143 144 +1
Continue to review full report at Codecov.
|
Currently JWT tokens are fairly hard to enable because GoogleCredentialsProvider will always set scopes on ServiceAccountCredentials. The only workaround is manually set FixCredentials.of(ServiceAccountJwtAccessCredentials). This PR enables automatic JWT tokens support for services that opt into it. The main limitation of JWT tokens is that they don't support scopes. So they can't be used when a user wants to explicitly limit a service account's permissions __within__ a service. (ie. using https://www.googleapis.com/auth/bigtable.data.readonly instead of https://www.googleapis.com/auth/bigtable.data). This should be a minority of users...most will just use the DEFAULT_SERVICE_SCOPES in their settings. To opt-in for JWT a client will need to register scopes that are equivalent to having full access to the target service (ie. https://www.googleapis.com/auth/bigtable.data and https://www.googleapis.com/auth/cloud-platform). To enable testing, I had to add powermock to mock GoogleCredentials.getApplicationDefault() inside GoogleCredentialsProvider
643a4da
to
2b9eab6
Compare
Now that JWT caching is available in google-auth-library, this is ready for review. @garrettjonesgoogle PTAL |
The class should be immutable, but it isn't. I created #526 to track this. If @igorbernstein2 wants to address it while working on this, please go ahead, but if not I'll fix it after this lands. LGTM |
package com.google.api.gax.core; | ||
|
||
import static com.google.common.truth.Truth.*; | ||
import static org.junit.Assert.*; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
LGTM
d728c68
to
4844558
Compare
@pongad I'm not sure I understand what you mean..It's an AutoValue class. Thanks for reviewing! I removed the star imports. Please merge when ready |
@igorbernstein2 Sorry I didn't explain well. Currently you can set the fields with an |
Currently JWT tokens are fairly hard to enable because GoogleCredentialsProvider will always set scopes on ServiceAccountCredentials. The only workaround is manually set
FixCredentials.of(ServiceAccountJwtAccessCredentials). This PR enables automatic JWT tokens support for services that opt into it.
The main limitation of JWT tokens is that they don't support scopes. So they can't be used when a user wants to explicitly limit a service account's permissions within a service. (ie. using https://www.googleapis.com/auth/bigtable.data.readonly instead of https://www.googleapis.com/auth/bigtable.data). This should be a minority of users...most will just use the DEFAULT_SERVICE_SCOPES in their settings.
To opt-in for JWT, a client will need to register scopes that are equivalent to having full access to the target service (ie. https://www.googleapis.com/auth/bigtable.data and https://www.googleapis.com/auth/cloud-platform).
The intended usage for this is that
EnhancedBigtableStubSettings.Builder
will:https://www.googleapis.com/auth/bigtable.data
,https://www.googleapis.com/auth/cloud-bigtable.data
andhttps://www.googleapis.com/auth/cloud-platform
asJwtEnabledScopes
To enable testing, I had to add powermock to mock GoogleCredentials.getApplicationDefault() inside GoogleCredentialsProvider
If this works out well, I would recommend to deprecate and remove the ability for users to configure custom scopes and try to use JWT tokens as much as possible.