Add ID token support to gcp-auth-extension#2999
Open
tknhs wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support in gcp-auth-extension for authenticating OTLP exports with Google-signed OIDC ID tokens (for IAM-protected OTLP endpoints such as Cloud Run / IAP), while keeping the default access token behavior unchanged for Google Cloud APIs (e.g., telemetry.googleapis.com).
Changes:
- Introduces
GOOGLE_OTEL_AUTH_TOKEN_TYPE(access_tokendefault, orid_token) plusGOOGLE_OTEL_AUTH_ID_TOKEN_AUDIENCEfor configuring ID token minting. - Implements ID token credential wrapping via
IdTokenCredentialsand skips GCP-specific quota/project behaviors when inid_tokenmode. - Adds unit tests for the new
id_tokenconfiguration path and updates the module README.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| gcp-auth-extension/src/main/java/io/opentelemetry/contrib/gcp/auth/GcpAuthAutoConfigurationCustomizerProvider.java | Adds token-type selection, ID token credential wrapping, and conditional behavior for quota/project attributes. |
| gcp-auth-extension/src/main/java/io/opentelemetry/contrib/gcp/auth/ConfigurableOption.java | Adds the two new configuration options and documents their semantics. |
| gcp-auth-extension/src/test/java/io/opentelemetry/contrib/gcp/auth/GcpAuthAutoConfigurationCustomizerProviderTest.java | Adds unit tests for ID token behavior, missing/invalid config handling, and unsupported token type. |
| gcp-auth-extension/README.md | Documents the new environment variables and when to use ID tokens vs access tokens. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Feature addition.
gcp-auth-extensioncurrently attaches an OAuth 2.0 access token from ADC, which works for Google Cloud endpoints liketelemetry.googleapis.combut not for OTLP endpoints protected by Google IAM (e.g. a Collector running on Cloud Run, or behind IAP), which require a Google-signed OIDC ID token with a matchingaud.This adds two config options:
GOOGLE_OTEL_AUTH_TOKEN_TYPE:access_token(default) orid_tokenGOOGLE_OTEL_AUTH_ID_TOKEN_AUDIENCE: audience for the ID token, required whenid_tokenFor
id_token, the extension wraps ADC inIdTokenCredentialsfor the given audience, and skips the quota-project header and thegcp.project_idresource attribute (both specific to the GCP APIs). Default behavior is unchanged, so this is backward compatible. This mirrors thetoken_type: id_tokenoption of the Collector'sgoogleclientauthextension.Existing Issue(s):
#2996
Testing:
id_tokenpath (audience present, HTTP/gRPC exporters, missing-audience and non-IdTokenProvider credential errors, unsupported token type).Documentation:
id_token(Cloud Run / IAP), including the audience semantics.