Skip to content

docs(auth): fix VerifyGoogleIdToken sample to call setCertificatesLocation - #100

Closed
lqiu96 wants to merge 14 commits into
mainfrom
docs/auth-0f-fix-verify-google-id-token-sample
Closed

lqiu96 wants to merge 14 commits into
mainfrom
docs/auth-0f-fix-verify-google-id-token-sample

Conversation

@lqiu96

@lqiu96 lqiu96 commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Update VerifyGoogleIdToken.java to call setCertificatesLocation(jwkUrl) instead of setIssuer(jwkUrl) and link the TokenVerifier.Builder#setCertificatesLocation reference documentation.

sakthivelmanii and others added 14 commits December 1, 2026 00:16
…gleapis#15316)

## Problem Statement
- After upgrading `fmt-maven-plugin` to `2.29` with long string
reflowing enabled in googleapis#15028, two test files in `google-cloud-spanner`
fail the module-wide `lint` check (`ConnectionOptionsTest.java` and
`GrpcInterceptorProviderTest.java`).

## Solution
- Run `fmt-maven-plugin:2.29:format` on `google-cloud-spanner` to reflow
five non-complying string literal concatenations in
`ConnectionOptionsTest.java` and `GrpcInterceptorProviderTest.java`
(formatting-only, no behavior change).
googleapis#15322)

## Problem Statement
- After upgrading `fmt-maven-plugin` to `2.29` with long string
reflowing enabled in googleapis#15028, 24 pre-existing files in
`java-bigquery-jdbc` fail the module-wide `lint` check (as tracked in
googleapis#15028's follow-up list).

## Solution
- Run `make lint` (`mvn com.spotify.fmt:fmt-maven-plugin:format` at
`2.29`) on `java-bigquery-jdbc` to reflow the 24 non-complying files
(formatting-only, no behavior change).

## Verification
- `mvn -B -ntp -T 1C -pl java-bigquery-jdbc -Dlint
com.spotify.fmt:fmt-maven-plugin:check` — `0` non-complying files.
- `mvn -B -ntp -T 1C -pl java-bigquery-jdbc -Dlint
checkstyle:check@checkstyle` — `0` Checkstyle violations.
- `mvn -B -ntp -Pquick-build test` in `java-bigquery-jdbc` — `1455` run,
`0` failures, `0` errors.
…n at FINEST logging (googleapis#15275)

## Problem Statement
- When `FINEST` logging is enabled for streaming queries in the Cloud
Spanner Java client, bound query parameter values and query options are
appended to the thrown `SpannerException` message.
- Because the mutated exception is returned to callers and recorded by
tracing integrations, sensitive bound parameter values can propagate
beyond the `FINEST` log record into application error logs, retry logs,
and OpenTelemetry/OpenCensus trace spans.

## Solution
- Always attach only the SQL text (without bound parameter values or
query options) to `SpannerException` when a streaming query fails,
regardless of the configured log level.
- Emit the full statement including bound parameters strictly inside the
`FINEST` log record message so opt-in `FINEST` diagnostics remain
available without leaking parameter values into thrown exceptions or
trace spans.
…ation (googleapis#15281)

## Problem Statement

- Connections configured with a custom `channelProvider` (such as a
custom TLS, mTLS, or proxy `ExternalChannelProvider`) shared the same
`SpannerPool` key as default connections or connections with a different
`channelProvider`, causing pooled clients to silently reuse an
unintended transport channel.
- Connections with an empty `channelProvider` or
`grpc_interceptor_provider` value (`""`) did not share a pool key with
connections where the property was omitted, even though both resolve to
the default behavior at runtime.

## Solution

- Include the configured `channelProvider` class name in the connection
pool key so each distinct `channelProvider` receives an isolated
`Spanner` client and transport channel while connections with the same
`channelProvider` continue to share a pool.
- Normalize empty `channelProvider` and `grpc_interceptor_provider`
values (`""`) to unset (`null`) so omitted and empty values share the
same default pool while whitespace or invalid class names continue to
fail closed.
…googleapis#15297)

## Summary

`.kokoro/build.sh` already tries to exclude generated `proto-*` modules
from the PR `lint` reactor (`# - proto-*/grpc-* are generated code and
should use the compiler format`), but its `proto-google-*` pattern
misses a few special non-`google-*` / monolithic modules. This PR
explicitly adds those outliers (`proto-data-manager-*`, `proto-admin-*`,
`proto-ad-manager-*`, and monolithic `java-grafeas`) so follow-up
adoption of `fmt-maven-plugin:2.29`
(`<skipReflowingLongStrings>false</skipReflowingLongStrings>`, googleapis#15028)
does not fail on `protoc`-generated files.

## Background

During generation, `librarian generate` runs `google-java-format`
`1.25.2` once on generated Java sources, producing the files checked in
on `main`. However, `google-java-format` `1.25.2`'s long-string
reflowing is not idempotent on `protoc` `descriptorData` strings in:

- `java-datamanager/proto-data-manager-v1` (11 `*Proto.java` files)
- `java-marketingplatformadminapi/proto-admin-v1alpha` (2 `*Proto.java`
files)
- `java-grafeas` (2 `protoc`-generated files:
`InTotoStatementProto.java`, `Discovery.java`)

Formatting these files a second time to satisfy `fmt:check` would cause
`librarian_generation_check.yaml` to fail on the next `librarian
generate --all` run on `main`.

## Changes

- Keeps `proto-google-*` (and the original `# - proto-*/grpc-*` comment)
unchanged rather than broadening to `proto-*`, avoiding any risk of
silently skipping a future handwritten `proto-*` module.
- Explicitly excludes `proto-data-manager-*`, `proto-admin-*`,
`proto-ad-manager-*` (the non-`google-*` generated proto module outlier
in `java-admanager`), and monolithic `java-grafeas`, with an added
comment explaining why.
- Keeps `grpc-google-*` unchanged because `grpc-gcp-java` is
handwritten, while generated `*Grpc.java` files only contain short
service/RPC name strings without `descriptorData` blobs and already pass
`fmt:check`.

Context: b/581031020
…ints and custom channel providers (googleapis#15272)

## Problem Statement
- Default-on built-in Cloud Monitoring metrics could still attempt to
export telemetry and credentials to `monitoring.googleapis.com` when a
client configured a custom `TransportChannelProvider` (such as an
`InstantiatingGrpcChannelProvider` with a custom endpoint or an opaque
provider) or a non-standard `setHost(...)` endpoint (including regional,
private/restricted, non-443, or non-HTTPS endpoints) without an explicit
`monitoringHost`.

## Solution
- Automatically disable default-on built-in Cloud Monitoring metrics
unless the effective Spanner endpoint matches the standard endpoint for
the resolved universe domain (`spanner.<universeDomain>:443` for
`InstantiatingGrpcChannelProvider`, or
`https://spanner.<universeDomain>[:443]` for `setHost(...)`), or
`monitoringHost` (`SpannerOptions.Builder.setMonitoringHost(...)` /
`SPANNER_MONITORING_HOST`) is explicitly configured.
- Mirror runtime channel selection precedence: an opaque
`TransportChannelProvider` or an `InstantiatingGrpcChannelProvider` with
an explicit endpoint takes precedence over `setHost(...)`; an
endpoint-less `InstantiatingGrpcChannelProvider` falls back to
`setHost(...)`.
- Suppress the auto-disable warning log when plaintext or
`NoCredentials` are configured.
- Document the unified endpoint and custom channel provider behavior in
`SpannerOptions.isEnableBuiltInMetrics()` Javadoc and the Spanner
README.

## Behavior Changes
- `setHost(...)` with regional (`*.rep.googleapis.com`),
`private.googleapis.com`, `restricted.googleapis.com`, non-443, or
non-HTTPS endpoints now auto-disables built-in Cloud Monitoring metrics
unless `monitoringHost` / `SPANNER_MONITORING_HOST` is explicitly set.
- `setHost(...)` combined with `setUniverseDomain(...)` keeps built-in
Cloud Monitoring metrics enabled only when the host matches
`https://spanner.<universeDomain>[:443]`.
- Auto-disable `WARNING` logs are also suppressed when `NoCredentials`
(or null credentials) are configured.
… correctly (googleapis#15282)

## Problem Statement
- On PostgreSQL-dialect Cloud Spanner connections, executing `SET
SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS = true` (or `TO true`) did not
exclude subsequent transactions from change streams and instead toggled
`SPANNER.RETURN_COMMIT_STATS`.
- As a result, transactions explicitly marked to be excluded from change
streams were still emitted to change streams, while commit statistics
were unexpectedly enabled.

## Solution
- Route PostgreSQL `SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS`
statements to the change-stream exclusion setting instead of the
commit-stats setting.
- Executing `SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS` after a
transaction has started or while a batch is active now fails with
`FAILED_PRECONDITION` instead of silently mutating
`SPANNER.RETURN_COMMIT_STATS`, matching GoogleSQL behavior.
…dPath fallback (googleapis#15283)

## Problem Statement
- When `java-spanner` falls back from DirectPath to CloudPath, the
CloudPath fallback channel unconditionally overwrites per-call
`CallCredentials` with the client's default credentials.
- Requests configured with narrower per-call or per-tenant credentials
via `SpannerOptions.CallCredentialsProvider` or
`CallContextConfigurator` silently execute under the broader client
default identity after fallback.

## Solution
- Preserve any existing per-call `CallCredentials` on outgoing
`CallOptions` during DirectPath-to-CloudPath fallback, and attach the
client's default credentials only when no call credentials are already
present.
- Construct the default `CallCredentials` wrapper once during channel
setup instead of allocating a new wrapper on every fallback RPC.
…ogleapis#15313)

Fix broken relative links and remove unused legacy reference links in
`google-auth-library-java/README.md`, add a module and BOM overview
table, fix the BOM README license from Apache 2.0 to BSD 3-Clause, and
update legacy `googleapis.dev` documentation URLs in
`.repo-metadata.json` and `pom.xml`.
…oogleapis#15312)

Remove internal shortlink references, replace an archived repository
issue link and dead README pointer with canonical documentation links,
and update legacy `cloud.google.com`, `http://`, and `tools.ietf.org`
URLs and section anchors across `google-auth-library-java`.
…ogleapis#15328)

## Summary

Formats 1 pre-existing non-complying file(s) in `grpc-gcp-java` using
`com.spotify.fmt:fmt-maven-plugin:2.29`
(`<skipReflowingLongStrings>false</skipReflowingLongStrings>`),
following googleapis#15028 (similar to googleapis#15300, googleapis#15302, googleapis#15316, googleapis#15322).
Formatting-only change with no behavioral impact.

## Verification

- `mvn -B -ntp -T 1C -pl grpc-gcp-java -Dlint
com.spotify.fmt:fmt-maven-plugin:check checkstyle:check@checkstyle`
(with `google-cloud-shared-config` from `main` installed locally): `0`
non-complying files and `0` Checkstyle violations.

Context: b/581031020
…gin (googleapis#15330)

## Summary

Formats 1 pre-existing non-complying file(s) in `java-logging-logback`
using `com.spotify.fmt:fmt-maven-plugin:2.29`
(`<skipReflowingLongStrings>false</skipReflowingLongStrings>`),
following googleapis#15028 (similar to googleapis#15300, googleapis#15302, googleapis#15316, googleapis#15322).
Formatting-only change with no behavioral impact.

## Verification

- `mvn -B -ntp -T 1C -pl java-logging-logback -Dlint
com.spotify.fmt:fmt-maven-plugin:check checkstyle:check@checkstyle`
(with `google-cloud-shared-config` from `main` installed locally): `0`
non-complying files and `0` Checkstyle violations.

Context: b/581031020
…ath when internal metrics are disabled (googleapis#15296)

## Problem

On the sessions path, `MetricsImpl.newTableTracer(...)` returned
`NoopVrpcTracer` immediately when `internalRecorder == null`. As a
result, disabling built-in Cloud Monitoring metrics
(`disableInternalMetrics()`) inadvertently dropped caller-owned
OpenTelemetry metrics (`CustomOpenTelemetryMetricsProvider` /
`userRecorder`) as well as custom `ApiTracerFactory` tracers
(`userTracerFactory`, such as the HBase metrics adapter), unlike the
classic path (`createTracerFactory(...)`).

## Solution

- Update `MetricsImpl.newTableTracer(...)` to add `internalRecorder`,
`userRecorder`, and custom `userTracerFactory` tracers independently.
- Skip wrapping the default no-op `BaseApiTracerFactory.getInstance()`
and return `NoopVrpcTracer.INSTANCE` when no tracers are active.

## Testing

- Added JUnit 5 tests in `MetricsIsolationTest` verifying
`newTableTracer(...)` records to `userRecorder` and invokes
`userTracerFactory` when `internalOtel == null`, invokes
`userTracerFactory` when both OTel instances are `null`, and returns
`NoopVrpcTracer.INSTANCE` when all are disabled.
- Ran `fmt-maven-plugin:format`, Enforcer, Checkstyle (0 violations),
AnimalSniffer, and `MetricsIsolationTest` (4/4 passing).
…ation

Fixes VerifyGoogleIdToken.java calling setIssuer(jwkUrl) instead of setCertificatesLocation(jwkUrl) (AUTH-0f, separated from AUTH-0a):
- TokenVerifier.Builder.setIssuer() validates the JWT iss claim (https://accounts.google.com), whereas setCertificatesLocation() overrides the JWK public-key endpoint URL.
- Verified locally with an RS256 loopback JWK server: setIssuer(jwkUrl) fails with VerificationException ("Expected issuer does not match"), while setCertificatesLocation(jwkUrl) succeeds.
- Adds link to the official TokenVerifier.Builder#setCertificatesLocation reference documentation.
@lqiu96
lqiu96 force-pushed the docs/auth-0f-fix-verify-google-id-token-sample branch from 2ae00cf to e475a9c Compare December 1, 2026 18:37
@lqiu96

lqiu96 commented Dec 1, 2026

Copy link
Copy Markdown
Owner Author

Opened upstream at googleapis#15345.

@lqiu96 lqiu96 closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants