Skip to content

ext_authz: add method_override to HttpService#44564

Open
derekargueta wants to merge 2 commits into
envoyproxy:mainfrom
derekargueta:dargueta-ext-authz-method-override
Open

ext_authz: add method_override to HttpService#44564
derekargueta wants to merge 2 commits into
envoyproxy:mainfrom
derekargueta:dargueta-ext-authz-method-override

Conversation

@derekargueta
Copy link
Copy Markdown
Member

@derekargueta derekargueta commented Apr 21, 2026

Fixes #5357.

The HTTP ext_authz filter forwards the original request's method to the authorization server verbatim. This means the auth server has to accept every HTTP method the upstream receives (GET, POST, DELETE, PATCH, etc.) rather than being able to expose a simple fixed endpoint like POST /auth. The gRPC ext_authz implementation doesn't have this problem since it always calls a single RPC.

This adds a method_override field to HttpService that, when set, substitutes the specified method on the outgoing authorization request. It pairs naturally with the existing path_override field — together they let you target a single fixed auth endpoint regardless of the original request.

  • Proto: method_override = 11 on HttpService, next-free-field bumped to 12
  • Implementation: validateMethodOverride() rejects values containing whitespace; applied in both encode_raw_headers and legacy header paths in RawHttpClientImpl::check()
  • Unit tests: override applied, passthrough when absent, raw headers path, combined method+path override, whitespace rejection, direct HttpService constructor
  • Integration test: end-to-end across all four parameterized variants (IPv4/IPv6 × legacy/raw headers)

Risk Level: low
Testing: unit & integration tests added
Docs Changes: done
Release Notes: done
Platform Specific Features: no

Adds a method_override field to the ext_authz HttpService config that,
when set, replaces the HTTP method on the outgoing authorization request.
Without this, the auth server must accept every method the upstream
receives (GET, DELETE, PATCH, etc.) rather than exposing a single fixed
endpoint like POST /auth.

Fixes envoyproxy#5357

Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #44564 was opened by derekargueta.

see: more, trace.

@derekargueta derekargueta marked this pull request as ready for review April 21, 2026 23:39
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #44564 was ready_for_review by derekargueta.

see: more, trace.

@derekargueta
Copy link
Copy Markdown
Member Author

CI failed due to a 504 gateway timeout when downloading

@derekargueta
Copy link
Copy Markdown
Member Author

/retest

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Please explain how does this fix #5357 (which AFIACT discusses other things other than overriding method).
After reviewing this PR I think I'm missing something fundamental. I've re-read the PR description, but I'm confused why gRPC is mentioned.

Comment thread changelogs/current.yaml
under the filter's configured name with a ``.shadow`` suffix
(``envoy.filters.http.ext_authz.shadow`` by default) so that a subsequent filter can read
and optionally enforce it.
- area: lua
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that this file includes many changes that don't need to be here. Can you please clean this?

// Only one of ``path_prefix`` or ``path_override`` may be set.
string path_override = 10;

// Overrides the HTTP method of the authorization request sent to the authorization service.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high-level question:
not sure I fully understand why the method needs an override or why it is dependent on the incoming request... Shouldn't it just be decided by the contents of server_uri?

} else {
headers->addCopy(key, header.raw_value());
}
} else if (key == Http::Headers::get().Method && !config_->methodOverride().empty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the else if needed here? if there's a :path header doesn't the :method need to be overridden?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ext_authz ignores uri with http_service

3 participants