feat(extauth): expose headersToClient in AuthorizationResponse for HTTP ext auth#13592
Conversation
4662912 to
9f64066
Compare
There was a problem hiding this comment.
Pull request overview
This PR significantly expands configuration and test support around Rustformation (Envoy dynamic module)–backed transformations, updates validation/runtime tooling to use an envoy-wrapper image, and refreshes a broad set of golden files and CI workflows. The scope goes well beyond the PR title/description (which focus on HTTP ext-auth headersToClient).
Changes:
- Switch/extend transformation plumbing and merge behavior to support Rustformation dynamic module configs (including deep-merge behavior and new template handling).
- Update validator and build/release plumbing for dynamic modules (envoy-wrapper image, module search path, multi-arch Envoy image selection).
- Add/adjust e2e and plugin test coverage plus many golden outputs/workflow updates (including new arm64 conformance matrix).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/features/transformation/testdata/transform-for-headers.yaml | Adds a header transformation case exercising header lookup/template behavior. |
| test/e2e/features/transformation/testdata/transform-for-body-local-reply.yaml | Adds new manifests for local-reply body transformation scenarios. |
| test/e2e/features/transformation/suite.go | Adds new test manifest/cases and adjusts rustformation toggling/expectations. |
| test/e2e/features/route_delegation/testdata/policy_merging.yaml | Updates transformation response semantics from add to set in test data. |
| test/e2e/features/route_delegation/suite.go | Skips the policy merging test (linked issue). |
| test/e2e/features/agentgateway/extauth/types.go | Adds a new manifest constant for a missing backendRef scenario. |
| test/e2e/features/agentgateway/extauth/testdata/secured-route-missing-ref.yaml | Adds a route/policy fixture with a missing ext-auth backendRef. |
| test/e2e/features/agentgateway/extauth/suite.go | Adds a new e2e test for missing backendRef behavior. |
| test/deployer/testdata/stats-matcher-inclusion-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/stats-matcher-exclusion-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/priority-class-name-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/omit-default-security-context-via-gw-out.yaml | Updates expected rendered output for securityContext deletion behavior. |
| test/deployer/testdata/omit-default-security-context-out.yaml | Updates expected rendered output for securityContext deletion behavior. |
| test/deployer/testdata/loadbalancer-static-ip-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/istio-enabled-waypoint-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/istio-enabled-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/gwc-with-replicas-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/envoy-infrastructure-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/envoy-controller-ignores-agentgateway-class-name-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/both-gwc-and-gw-have-params-reversed-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/both-gwc-and-gw-have-params-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/base-gateway-tls-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/base-gateway-out.yaml | Updates expected Envoy HCM config (normalize_path/merge_slashes, formatting). |
| test/deployer/testdata/agentgateway-omitdefaultsecuritycontext.yaml | Updates overlay examples to demonstrate $patch: delete vs null. |
| test/deployer/testdata/agentgateway-omitdefaultsecuritycontext-ref-gwp-on-gw.yaml | Updates overlay examples to demonstrate $patch: delete vs null. |
| test/deployer/testdata/agentgateway-omitdefaultsecuritycontext-ref-gwp-on-gw-out.yaml | Updates expected output to reflect empty securityContext rendering. |
| test/deployer/testdata/agentgateway-omitdefaultsecuritycontext-out.yaml | Updates expected output to reflect empty securityContext rendering. |
| test/deployer/internal_helm_test.go | Improves helm test documentation and updates validator used for securityContext expectations. |
| test/deployer/deployer_helm.go | Adds EmptySecurityContextValidator and clarifies validator semantics. |
| pkg/validator/validator.go | Switches default Envoy image to envoy-wrapper and adjusts validation invocation behavior. |
| pkg/kgateway/utils/any.go | Adds helpers to convert Any(StringValue(JSON)) ⇄ Go objects for rustformation config merging. |
| pkg/kgateway/translator/gateway/testutils/outputs/traffic-policy/transformation-deep-merge.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/traffic-policy/merge.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/traffic-policy/label_based_global_policy.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/traffic-policy/label_based.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/status/basic.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/policy/policy-transformation-malformed-template-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/policy/policy-template-structure-invalid-out.yaml | Updates strict-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/attachment/xlistenerset-listener-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/attachment/xlistenerset-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/attachment/multi-target-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/attachment/httproute-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/attachment/gateway-listener-merge-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/attachment/gateway-listener-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/strict/attachment/gateway-invalid-out.yaml | Updates strict-mode error message golden output for dynamic module behavior. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/standard/attachment/xlistenerset-listener-invalid-out.yaml | Updates standard-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/standard/attachment/xlistenerset-invalid-out.yaml | Updates standard-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/standard/attachment/multi-target-invalid-out.yaml | Updates standard-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/standard/attachment/httproute-invalid-out.yaml | Updates standard-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/standard/attachment/gateway-listener-merge-invalid-out.yaml | Updates standard-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/standard/attachment/gateway-listener-invalid-out.yaml | Updates standard-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/route-replacement/standard/attachment/gateway-invalid-out.yaml | Updates standard-mode golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/httplistenerpolicy/preserve-external-request-id.yaml | Re-formats/updates golden output (normalizePath/mergeSlashes ordering/structure). |
| pkg/kgateway/translator/gateway/testutils/outputs/httplistenerpolicy/generate-request-id-false.yaml | Re-formats/updates golden output (normalizePath/mergeSlashes ordering/structure). |
| pkg/kgateway/translator/gateway/testutils/outputs/discovery-namespace-selector/base_select_infra.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/discovery-namespace-selector/base_select_all.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/traffic_policy_multi_level_inheritance_override_enabled.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/traffic_policy_multi_level_inheritance_override_disabled.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/traffic_policy_inheritance_child_override_ok.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/traffic_policy_inheritance_child_override_ignore.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/traffic_policy_inheritance.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/traffic_policy_filter_override_merge.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/traffic_policy.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/testutils/outputs/delegation/policy_deep_merge.yaml | Updates golden output to dynamic module filter config format. |
| pkg/kgateway/translator/gateway/gateway_translator_test.go | Disables certain strict validation tests pending rustformation capabilities. |
| pkg/kgateway/setup/testdata/standard/transformation-out.yaml | Updates setup golden outputs to dynamic module filter config format. |
| pkg/kgateway/setup/testdata/standard/transform-route-only-out.yaml | Updates setup golden outputs to dynamic module filter config format. |
| pkg/kgateway/setup/testdata/standard/transform-gw-only-out.yaml | Updates setup golden outputs to dynamic module filter config format. |
| pkg/kgateway/setup/testdata/standard/transform-gw-and-route-disable-out.yaml | Updates setup golden outputs to dynamic module filter config format. |
| pkg/kgateway/setup/testdata/standard/routeoptions-out.yaml | Updates setup golden outputs to dynamic module filter config format. |
| pkg/kgateway/setup/testdata/standard/lambda-qualifiers-out.yaml | Removes trailing whitespace in golden output. |
| pkg/kgateway/setup/testdata/standard/extproc-targetref-out.yaml | Updates endpoint ordering/locality formatting in golden output. |
| pkg/kgateway/setup/testdata/standard/extproc-routerule-out.yaml | Updates endpoint ordering/locality formatting in golden output. |
| pkg/kgateway/helm/envoy/templates/configmap.yaml | Adds normalize_path/merge_slashes to HCM config in helm template. |
| pkg/kgateway/extensions2/plugins/trafficpolicy/transformation_plugin.go | Fixes transformation IR construction gating when rustformations are enabled. |
| pkg/kgateway/extensions2/plugins/trafficpolicy/traffic_policy_plugin.go | Adds deprecation warning and adjusts local rate limit filter staging. |
| pkg/kgateway/extensions2/plugins/trafficpolicy/merge.go | Implements rustformation deep-merge behavior by merging JSON filter configs. |
| pkg/kgateway/extensions2/plugins/listenerpolicy/listener_plugin.go | Fixes equality logic to include HTTP listener policy sub-IR comparison. |
| pkg/kgateway/agentgatewaysyncer/workloads.go | Exports WorkloadToAddress and centralizes workload address population logic. |
| pkg/kgateway/agentgatewaysyncer/syncer.go | Adds injectable address provider hooks for workloads/services when AsAddress isn’t populated. |
| pkg/kgateway/agentgatewaysyncer/service.go | Centralizes service address population logic. |
| pkg/kgateway/agentgatewaysyncer/option.go | Adds new syncer options for address provider functions. |
| pkg/agentgateway/plugins/testdata/trafficpolicy/http-route-missing-not-attached.yaml | Adds plugin test fixture for missing HTTPRoute attachment. |
| pkg/agentgateway/plugins/testdata/trafficpolicy/http-route-ancestor-gateway.yaml | Adds plugin test fixture validating ancestor gateway selection. |
| pkg/agentgateway/plugins/testdata/trafficpolicy/gateway-missing-not-attached.yaml | Adds plugin test fixture for missing Gateway attachment. |
| pkg/agentgateway/plugins/testdata/trafficpolicy/extauthz-missing-backend.yaml | Adds plugin test fixture for missing extAuth backend service. |
| pkg/agentgateway/plugins/testdata/trafficpolicy/_defaults.yaml | Adds shared defaults fixture for trafficpolicy tests. |
| pkg/agentgateway/plugins/testdata/frontendpolicy/tls.yaml | Adds gateway defaults to frontendpolicy fixture. |
| pkg/agentgateway/plugins/testdata/frontendpolicy/tls-listener-no-gw.yaml | Adds fixture for missing gateway attachment in frontend TLS policy. |
| pkg/agentgateway/plugins/testdata/frontendpolicy/tcp-keepalive.yaml | Adds gateway defaults to frontendpolicy fixture. |
| pkg/agentgateway/plugins/testdata/frontendpolicy/http.yaml | Adds gateway defaults to frontendpolicy fixture. |
| pkg/agentgateway/plugins/testdata/frontendpolicy/full.yaml | Adds gateway defaults to frontendpolicy fixture. |
| pkg/agentgateway/plugins/testdata/frontendpolicy/_defaults.yaml | Adds shared defaults fixture for frontendpolicy tests. |
| pkg/agentgateway/plugins/testdata/backendpolicy/simple.yaml | Updates ancestor kind in expected status output. |
| pkg/agentgateway/plugins/testdata/backendpolicy/mcp-authz-route.yaml | Updates ancestor kind in expected status output. |
| pkg/agentgateway/plugins/testdata/backendpolicy/httproute-missing-not-attached.yaml | Adds plugin test fixture for missing HTTPRoute backendpolicy attachment. |
| pkg/agentgateway/plugins/testdata/backendpolicy/backend-missing-not-attached.yaml | Adds plugin test fixture for missing AgentgatewayBackend attachment. |
| pkg/agentgateway/plugins/testdata/backendpolicy/backend-ancestor-backend.yaml | Adds plugin test fixture for backend ancestor status behavior. |
| pkg/agentgateway/plugins/testdata/backendpolicy/awsauth.yaml | Updates ancestor kind in expected status output. |
| pkg/agentgateway/plugins/testdata/backendpolicy/ai.yaml | Updates ancestor kind in expected status output. |
| pkg/agentgateway/plugins/testdata/backendpolicy/_defaults.yaml | Adds shared defaults fixture for backendpolicy tests. |
| internal/envoyinit/transformations/src/lib.rs | Adjusts transformation config struct derivations. |
| internal/envoyinit/transformations/src/jinja.rs | Adds template pre-compilation/lookup and case-insensitive header access behavior. |
| internal/envoyinit/transformations/Cargo.toml | Enables minijinja loader feature. |
| internal/envoyinit/rustformations/src/lib.rs | Adds arch-specific SDK wiring for envoy dynamic modules. |
| internal/envoyinit/rustformations/src/http_simple_mutations.rs | Implements env/template caching, local reply body handling, and arch-specific add-header behavior. |
| internal/envoyinit/rustformations/Cargo.toml | Adds target-specific dependencies for local vs remote SDK builds. |
| internal/envoyinit/patched-envoy-sdk/envoy-proxy-dynamic-modules-rust-sdk/dynamic_modules/sdk/rust/src/lib.rs | Minor formatting fix in patched SDK code. |
| internal/envoyinit/Cargo.toml | Removes git patch override block (patched SDK handling changes). |
| internal/envoyinit/Cargo.lock | Updates lockfile for new deps/feature flags and dual-SDK sources. |
| install/helm/kgateway-crds/templates/gateway.kgateway.dev_trafficpolicies.yaml | Updates CRD schema descriptions about arm64 add-header limitation. |
| hack/kind/setup-kind.sh | Improves Gateway API CRD installation logic (release vs kustomize based on ref). |
| hack/bump_deps.sh | Adds helpers to update Makefile/workflow pins and improves gateway-api bump flow. |
| docs/guides/transformation.md | Adds documentation describing classic vs rustformation differences and limitations. |
| api/v1alpha1/kgateway/traffic_policy_types.go | Adds API comment about arm64 add-header limitation. |
| api/v1alpha1/agentgateway/agentgateway_parameters_types.go | Clarifies overlay semantics for $patch: delete, null, and $patch: replace. |
| api/settings/settings_test.go | Updates expectations for default/use of rustformations flag. |
| api/settings/settings.go | Changes default UseRustFormations to true and adds strict-mode note. |
| Makefile | Adds per-arch Envoy image vars, updates CRD install logic, and refactors sections. |
| .goreleaser.yaml | Uses per-arch Envoy image build args for multi-arch releases. |
| .github/workflows/release.yaml | Adds support for release branches matching vX.Y.x. |
| .github/workflows/nightly-tests.yaml | Bumps Gateway API versions in the nightly matrix. |
| .github/workflows/conformance.yaml | Adds an arch matrix and arm64 runner selection for conformance jobs. |
|
/kind feature |
|
Thanks @babakzarrinbal for raising this. Could you please add tests around this ? Thanks |
|
@davidjumani |
@babakzarrinbal Thank you for the contribution, can you follow https://github.com/kgateway-dev/kgateway/blob/main/devel/contributing/README.md to create the DCO and make verify to pass the lint check. |
|
This pull request has been marked as stale because of no activity in the last 30 days. It will be closed in the next 5 days unless it is tagged "no stalebot" or other activity occurs. |
…TP ext auth Add HeadersToClient field to AuthorizationResponse which maps to Envoy's AllowedClientHeaders. This allows headers from the auth service denial response (e.g. Location on a 302 redirect) to be forwarded back to the downstream client, enabling redirect-based OAuth2 flows without an additional relay component. Signed-off-by: Babak Zarrinbal <[email protected]>
Signed-off-by: Babak Zarrinbal <[email protected]>
Regenerate the CRD YAML to include the headersToClient field in AuthorizationResponse. This was missing from the initial commit. Signed-off-by: Babak Zarrinbal <[email protected]>
d8f8033 to
8f42b52
Compare
@andy-fong |
|
@babakzarrinbal Just noticed this behavior change in envoy 1.37 release note: does that affect what you do? Maybe we can add the allowed_client_headers_on_success as well? |
|
@babakzarrinbal somehow your last commit is missing DCO again, would you be able to fix that. Might need to amend the last commit and force push. |
…for HTTP ext auth Signed-off-by: Babak Zarrinbal <[email protected]>
a52bd47 to
049cb62
Compare
|
@andy-fong DCO fixed - amended the last commit and force-pushed. All 4 commits now have valid sign-offs. Thanks for the heads up! |
|
@babakzarrinbal Sorry. Have been quite busy the past couple weeks. Looks like you need to run "make generate-all" again after you added "headersToClientOnSuccess". |
Signed-off-by: Babak Zarrinbal <[email protected]>
|
@andy-fong done — ran the codegen and pushed; the regenerated |
Description
Adds
headersToClientandheadersToClientOnSuccesstoAuthorizationResponseinExtHttpService, mapping to Envoy'sallowed_client_headersandallowed_client_headers_on_success.Fixes #13594.
Problem
When using
httpServicefor ext auth with an external oauth2-proxy, unauthenticated requests receive a403from the gateway even though the auth service returns a302 + Locationredirect. Envoy'sAllowedClientHeaderswas never set, so the redirect headers were stripped on denial and never reached the browser.Solution
Expose
headersToClient(denial path) andheadersToClientOnSuccess(allow path) on the CRD type and wire them toAllowedClientHeaders/AllowedClientHeadersOnSuccessin the Envoy ext_authz config builder. This lets redirect headers pass through to the client, enabling oauth2-proxy redirect flows without an in-cluster nginx/gRPC adapter.Changes
api/v1alpha1/kgateway/gateway_extensions_types.go: addHeadersToClientandHeadersToClientOnSuccesstoAuthorizationResponse.api/v1alpha1/kgateway/zz_generated.deepcopy.go: deepcopy for the new fields.install/helm/kgateway-crds/templates/gateway.kgateway.dev_gatewayextensions.yaml: regenerated CRD.pkg/kgateway/extensions2/plugins/trafficpolicy/gateway_extension.go: wire the fields toAllowedClientHeaders/AllowedClientHeadersOnSuccess.pkg/kgateway/extensions2/plugins/trafficpolicy/gateway_extension_test.go: unit coverage for the new wiring.Usage
Change Type
/kind feature
Changelog