GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(oauth2): support certificate-bound OAuth2 tokens and mTLS rotation for Workload Identity Federation by macastelaz · Pull Request #14781 · googleapis/google-cloud-java Conversation
|
| */ | ||
| FileIdentityPoolSubjectTokenSupplier(IdentityPoolCredentialSource credentialSource) { | ||
| this.credentialSource = credentialSource; | ||
| this.credentialSource = checkNotNull(credentialSource, "credentialSource cannot be null"); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
qq: From what I see FileIdentityPoolSubjectTokenSupplier is an existing class, is this guaranteed to not be a behavior change? Would null credentialSource worked before?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
FileIdentityPoolSubjectTokenSupplier is package-private (class FileIdentityPoolSubjectTokenSupplier) and is only instantiated inside IdentityPoolCredentials after verifying credentialSource != null. Previously, a null credentialSource would have thrown a NullPointerException on the first call to getSubjectToken() (at credentialSource.getCredentialLocation()); Preconditions.checkNotNull fails fast with the same NullPointerException at construction time.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "Actor tokens are only supported for JSON-formatted credential files with distinct field" | ||
| + " names."); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
qq: What does distinct field names mean in this case? This is checking for format type == text, but the error message suggests something else
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Updated the error message in e05fa17 to "Actor tokens are only supported for JSON-formatted credential files."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| static String parseToken(InputStream inputStream, IdentityPoolCredentialSource credentialSource) | ||
| throws IOException { | ||
| if (credentialSource.credentialFormatType == CredentialFormatType.TEXT) { | ||
| private String getToken(@Nullable String targetFieldName) throws IOException { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
qq, should targetFieldName allowed to be nullable? What cases would be supported for this? Would it just be easier to assert non-null here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
targetFieldName is null when reading a TEXT-formatted subject token: getSubjectToken() passes credentialSource.subjectTokenFieldName, which is null for TEXT format (since the entire file content is read as the raw token string rather than extracting a JSON field). Added an explanatory comment above getToken in e05fa17 to clarify this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| static boolean isDefaultOrMtlsTransportFactory(@Nullable HttpTransportFactory transportFactory) { | ||
| return transportFactory == null | ||
| || transportFactory instanceof OAuth2Utils.DefaultHttpTransportFactory | ||
| || transportFactory.getClass() == MtlsHttpTransportFactory.class | ||
| || (transportFactory instanceof MtlsHttpTransportFactory | ||
| && !((MtlsHttpTransportFactory) transportFactory).hasKeyStore()); | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: I think I've seen this type of check added a few times now. I wonder if this can be put in a shared util?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done in e05fa17 — moved isDefaultOrMtlsTransportFactory, hasMtlsKeyStore, and isKeylessMtlsTransportFactory into OAuth2Utils and updated IdentityPoolCredentials and ImpersonatedCredentials to use the shared helpers.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ImpersonatedCredentials impersonated = getImpersonatedCredentials(); | ||
| if (impersonated != null) { | ||
| return impersonated.refreshAccessToken(); | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't recall the logic for this from the old PRs, can you add a comment that explains this logic and why it's needed?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done in e05fa17 — added an inline comment in both PluggableAuthCredentials and AwsCredentials explaining why getImpersonatedCredentials() must be reconciled with the parent builder's transportFactory when service account impersonation is configured.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (content == null || content.trim().isEmpty()) { | ||
| OAuthException oauthException = | ||
| new OAuthException( | ||
| "http_error_" + e.getStatusCode(), e.getStatusMessage(), null, e.getStatusCode()); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
qq, what is this format string exception http_error_{status}_{message}? I think it may just be clearer as a string
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Those are actually two separate arguments to the OAuthException(String errorCode, @Nullable String errorDescription, @Nullable String errorUri) constructor ("http_error_" + e.getStatusCode() is errorCode, and e.getStatusMessage() is errorDescription), rather than a single concatenated string. OAuthException enforces Preconditions.checkNotNull(errorCode) and formats the message as "Error code " + errorCode + ": " + errorDescription. Added an inline comment in e05fa17 to make this clearer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| JsonParser parser = OAuth2Utils.JSON_FACTORY.createJsonParser(content); | ||
| GenericJson errorResponse = parser.parseAndClose(GenericJson.class); | ||
| if (errorResponse == null) { | ||
| OAuthException oauthException = | ||
| new OAuthException( | ||
| "http_error_" + e.getStatusCode(), e.getStatusMessage(), null, e.getStatusCode()); | ||
| oauthException.initCause(e); | ||
| return oauthException; | ||
| } | ||
|
|
||
| String errorCode = null; | ||
| String errorDescription = null; | ||
| Object rawError = errorResponse.get("error"); | ||
| if (rawError instanceof String) { | ||
| errorCode = (String) rawError; | ||
| } else if (rawError instanceof Map) { | ||
| Map<?, ?> errorMap = (Map<?, ?>) rawError; | ||
| if (errorMap.get("status") instanceof String) { | ||
| errorCode = (String) errorMap.get("status"); | ||
| } | ||
| if (errorMap.get("message") instanceof String) { | ||
| errorDescription = (String) errorMap.get("message"); | ||
| } | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: Can you add comments to explain what this big block of code is doing? This looks to be parsing out status/ messages from the error details? What is the format of that
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done in e05fa17 — added inline comments documenting the two JSON error formats supported here (standard OAuth 2.0 RFC 6749 flat JSON {"error": "...", "error_description": "...", "error_uri": "..."} from the STS token endpoint vs. nested Google API Standard Error google.rpc.Status JSON {"error": {"code": 401, "status": "UNAUTHENTICATED", "message": "..."}} from the IAM Credentials API) and the fallback order.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…nsport helpers
| // Token and IAM endpoints can return errors in two JSON schemas: | ||
| // 1. RFC 6749 Section 5.2 OAuth 2.0 format, where "error" is a top-level String: | ||
| // {"error": "invalid_grant", "error_description": "...", "error_uri": "..."} | ||
| // 2. Google API Standard Error format (google.rpc.Status / AIP-193), returned by GFE/STS on | ||
| // mTLS or HTTP 401/403 authentication errors, where "error" is a nested JSON object: | ||
| // {"error": {"code": 401, "status": "UNAUTHENTICATED", "message": "..."}} |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. This is for the token/ IAM endpoints, does the above check come from a different endpoint response?
This method is a bit long, can the token/ IAM endpoint logic here be moved to a helper?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The whole createFromHttpResponseException method handles error responses from the OAuth, STS, and IAM endpoints — the checks above (content == null || content.trim().isEmpty() and errorResponse == null) are just the guards for when an HTTP error response has an empty or null body before inspecting the parsed JSON fields.
Extracted the JSON field extraction into a createFromJsonErrorResponse helper in 65d592b and updated the comments to make that distinction clearer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is merging already reviewed code into main. Reviewed the new changes and those LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
🤖 I have created a release *beep* *boop* --- <details><summary>1.95.0</summary> ## [1.95.0](v1.94.0...v1.95.0) (2026-11-02) ### Features * **bigquery-jdbc:** expose BigQueryResultSetMetadata and getField(int) ([#14761](#14761)) ([f01245a](f01245a)) * **gax:** align resumable upload chunk size to server granularity and surface effective chunk size ([#14670](#14670)) ([6cbb096](6cbb096)) * **google/cloud/designcenter/v1:** add designcenter ([#14823](#14823)) ([01d27dc](01d27dc)) * **google/cloud/observability/v1:** add observability ([#14722](#14722)) ([624f28e](624f28e)) * **oauth2:** support certificate-bound OAuth2 tokens and mTLS rotation for Workload Identity Federation ([#14781](#14781)) ([dcb29b0](dcb29b0)) * **storage:** add bucket IP filtering samples and tests ([#14328](#14328)) ([cb2b726](cb2b726)) * **storage:** add support for DirectPath over Interconnect ([#14006](#14006)) ([ad0eb94](ad0eb94)) * **storage:** OpenTelemetry client metrics configuration and options ([#14484](#14484)) ([7c29e48](7c29e48)) * **storage:** OpenTelemetry client metrics instrument registry and views ([#14398](#14398)) ([60233b7](60233b7)) ### Bug Fixes * add user agent to session path ([#14835](#14835)) ([a653638](a653638)) * **auth:** align mTLS transport and bound token certificate startup polling and well-known discovery ([#14748](#14748)) ([0bae268](0bae268)) * **bigquery-jdbc:** expand handling to OOM errors ([#14759](#14759)) ([7d4b921](7d4b921)) * **bigquery-jdbc:** fix naive fallback of parameter count ([#14779](#14779)) ([c3e4a5b](c3e4a5b)) * **bigquery-jdbc:** format RANGE bounds consistently across REST and Arrow ([#14807](#14807)) ([2108b8e](2108b8e)) * **bigquery-jdbc:** parse scientific-notation epoch TIMESTAMPs ([#14777](#14777)) ([71a31b1](71a31b1)) * **bigquery-jdbc:** preserve pre-1582 and pre-standard-time DATE/DATETIME digits ([#14787](#14787)) ([3dc394f](3dc394f)) * **bigtable:** avoid mutating Query in-place in createPointReadCallable ([#14797](#14797)) ([1b1c6a7](1b1c6a7)) * **bigtable:** check isOk and getRejected first in RetryingVRpc.shouldRetry ([#14795](#14795)) ([d821bd3](d821bd3)) * **bigtable:** check remaining deadline on client-initiated retries in RetryingVRpc ([#14796](#14796)) ([a04e24c](a04e24c)) * **bigtable:** Fix empty RowResult semantics in TestProxy. ([#14810](#14810)) ([1d2fb9a](1d2fb9a)) * **bigtable:** include reversed in Query equals, hashCode, and toString ([#14799](#14799)) ([fe9232b](fe9232b)) * **bigtable:** pass cell value size to RowBuilder.startCell in RowBuilderShim ([#14800](#14800)) ([cfa7949](cfa7949)) * **bigtable:** reject empty split points in RowSetUtil and clarify QueryPaginator Javadoc ([#14811](#14811)) ([1bc507f](1bc507f)) * **bigtable:** remove legacy PollingConfiguration migration in ClientConfigurationManager ([#14822](#14822)) ([95ead45](95ead45)) * **bigtable:** resolve session diversion through a single shared rule ([#14738](#14738)) ([00f7bea](00f7bea)) * **bigtable:** respect query limit smaller than pageSize and avoid mutating Query in QueryPaginator ([#14821](#14821)) ([cecd09e](cecd09e)) * **firestore:** graduate pipeline search from preview to GA ([#14741](#14741)) ([a993026](a993026)) * **gax:** do not treat a SocketTimeoutException as a thread interrupt ([#14778](#14778)) ([7b91805](7b91805)) * **jdbc:** populate `ResultSetMetaData` on empty `DatabaseMetaData` resultsets ([#14809](#14809)) ([4c6a7e3](4c6a7e3)) * **pubsub:** make publish hedging robust to clock jumps, queue errors, and shutdown ([#14860](#14860)) ([9b9e2a5](9b9e2a5)) * **spanner:** attach routing hints to read-write transaction requests ([#14786](#14786)) ([54e0585](54e0585)) * **spanner:** cancel queries promptly on close and synchronize error handling ([#14887](#14887)) ([323a8f7](323a8f7)) * **spanner:** do not cache retryable errors in AbstractLazyInitializer ([#14752](#14752)) ([6a9ac76](6a9ac76)) * **spanner:** restore setCall overload for stream test compatibility ([#14885](#14885)) ([cfe728e](cfe728e)) * **spanner:** synchronize stream lifecycle and retry buffering in ResumableStreamIterator ([#14770](#14770)) ([4edefc5](4edefc5)) * **spanner:** trigger best-effort rollback on indeterminate commit failures ([#14831](#14831)) ([b9d1b95](b9d1b95)) * **storage:** preserve HTTP status for XML multipart upload errors so retries work ([#14804](#14804)) ([3c03034](3c03034)) * **storage:** send destination on gRPC copy when target BlobInfo is provided ([#14784](#14784)) ([43a67a0](43a67a0)) * **storage:** validate CRC32C on HTTP downloads that were not decompressed ([#14805](#14805)) ([61aa22f](61aa22f)) ### Documentation * **bigtable:** document that skipped large rows count towards row limit ([#14801](#14801)) ([91d60e0](91d60e0)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…14914) ## Summary Automatically syncs the `oidc-jwt-1` Workload Identity Pool Provider's static `jwksJson` in `ITWorkloadIdentityFederationTest` whenever the integration test service account (`[email protected]`) rotates keys bi-monthly (`java_it_service_account_rotation`). ### Background * The 4 mTLS + `actor_token` Workload Identity Federation tests added in #14781 sign mock OIDC JWTs with `[email protected]`'s private key (`GOOGLE_APPLICATION_CREDENTIALS`), verified against the `oidc-jwt-1` OIDC provider in `gcloud-devel`. * When `it-service-account` rotates keys every two months, the new `private_key_id` (`kid`) is not in `oidc-jwt-1`'s static `jwksJson`, causing STS token exchange to fail with `400 Bad Request: Invalid JWT signature`. * Because `ITWorkloadIdentityFederationTest` runs authenticated as `[email protected]`—which already holds `roles/iam.workloadIdentityPoolAdmin` on `gcloud-devel`—`ensureOidcJwtProviderJwksSynced()` checks once per test run whether `oidc-jwt-1`'s `jwksJson` includes `privateKeyId`. On the first run after a key rotation, it fetches the service account's live public JWK set (`https://www.googleapis.com/service_accounts/v1/jwk/<client_email>`) and patches `oidc-jwt-1`. See https://docs.google.com/document/d/1cjtmXb4tGZgyvTgL2hfn96KaNnAukdt6FJ8j4CV2H_k/view for more details
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.