envoyproxy / envoyproxy/envoy

gcp_authn: Deprecation of http_uri breaks use cases where ?format=full must be used

Open
#35,651 13 comments 0 reactions 0 assignees View on GitHub
area/gcp_authn enhancement no stalebot
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 20h
Merged PRs (30d)
437

Description

*Title*: *gcp_authn: Deprecation of http_uri breaks use cases where ?format=full must be used*

*Description*:
Prior to #35173, users were able to use the `http_uri` config to set the URL pattern that should be used when obtaining an ID token from the GCP metadata server. After #35173, the attribute is marked as deprecated and says that it will be going away in a future version.

The normal GCP metadata URL also accepts a `?format=full` query parameter which adds additional useful attributes to the ID token that are needed for some use cases. Specifically, the `full` token format adds the following attributes: `email`, `google.compute_engine.instance_id`, `google.compute_engine.instance_name`, `google.compute_engine.project_id`, `google.compute_engine.project_number`, and `google.compute_engine.zone`.

This full token format is also accessible by running `gcloud auth print-identity-token --audiences= --token-format=full`.

With the deprecation of `http_uri` config, there is no longer a non-deprecated way to set the token format that the `gcp_authn` filter should use which breaks use cases where remote hosts require those attributes to be present in the ID token.

One potential fix would be to introduce a parameter that would allow a user to specify the token format (either `standard` or `full`).

*Repro steps*:
I've included a configuration below demonstrating the usage of the `http_uri` config to set the `format=full` query parameter. Prior to #35173, you simply added the query parameter to the URL and the appropriate `full` token would be added to the request as expected.

After #35173, it is necessary to workaround the deprecation by setting `envoy.reloadable_features.gcp_authn_use_fixed_url` to `false`

*Config*:
```
static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 10000
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
access_log:
- name: envoy.access_loggers.stdout
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
host_rewrite_literal: some-host-needing-gcp-auth
cluster: remote
http_filters:
- name: "envoy.filters.http.gcp_authn"
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.gcp_authn.v3.GcpAuthnFilterConfig
http_uri:
uri: "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=[AUDIENCE]&format=full"
cluster: "gcp_authn"
timeout: 10s
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

clusters:
- name: remote
type: LOGICAL_DNS
# Comment out the following line to test on v6 networks
dns_lookup_family: V4_ONLY
load_assignment:
cluster_name: remote
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: some-host-needing-gcp-auth
port_value: 443
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: some-host-needing-gcp-auth
metadata:
typed_filter_metadata:
envoy.filters.http.gcp_authn:
"@type": type.googleapis.com/envoy.extensions.filters.http.gcp_authn.v3.Audience
url: https://some-host-needing-gcp-auth
- name: gcp_authn
type: STRICT_DNS
connect_timeout: 5s
dns_lookup_family: V4_ONLY
load_assignment:
cluster_name: "gcp_authn"
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: "metadata.google.internal"
port_value: 80

layered_runtime:
layers:
- name: "static"
static_layer:
envoy.reloadable_features.gcp_authn_use_fixed_url: false
```

*Logs*:
```
[2024-08-09 19:31:53.072][8769][warning][misc] [source/common/protobuf/message_validator_impl.cc:21] Deprecated field: type envoy.extensions.filters.http.gcp_authn.v3.GcpAuthnFilterConfig Using deprecated option 'envoy.extensions.filters.http.gcp_authn.v3.GcpAuthnFilterConfig.http_uri' from file gcp_authn.proto. This configuration will be removed from Envoy soon. Please see https://www.envoyproxy.io/docs/envoy/latest/version_history/version_history for details. If continued use of this field is absolutely necessary, see https://www.envoyproxy.io/docs/envoy/latest/configuration/operations/runtime#using-runtime-overrides-for-deprecated-features for how to apply a temporary and highly discouraged override.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.