Skip to content

ext_authz: add grpc_service field on the per-route filter#40169

Merged
agrawroh merged 17 commits intoenvoyproxy:mainfrom
agrawroh:ext-authz-cluster
Aug 22, 2025
Merged

ext_authz: add grpc_service field on the per-route filter#40169
agrawroh merged 17 commits intoenvoyproxy:mainfrom
agrawroh:ext-authz-cluster

Conversation

@agrawroh
Copy link
Member

@agrawroh agrawroh commented Jul 9, 2025

Description

This PR adds support for per-route gRPC service override in the ext_authz HTTP filter, allowing different routes to use different external authorization backends. Routes would now be able to specify a different authorization service by configuring grpc_service in the per-route check_settings.


Commit Message: ext_authz: add grpc_service field on the per-route filter
Additional Description: Add a new grpc_service field on the per-route ExtAuthZ filter to be able to override the AuthService backend on a per-route basis.
Risk Level: Low
Testing: Added Unit & Integration Tests
Docs Changes: Added
Release Notes: Added

@repokitteh-read-only
Copy link

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: #40169 was opened by agrawroh.

see: more, trace.

@repokitteh-read-only
Copy link

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

🐱

Caused by: #40169 was opened by agrawroh.

see: more, trace.

@agrawroh agrawroh force-pushed the ext-authz-cluster branch from 0f6aadb to cad4ca6 Compare July 9, 2025 20:33
@agrawroh
Copy link
Member Author

agrawroh commented Jul 9, 2025

/retest

@agrawroh agrawroh force-pushed the ext-authz-cluster branch 5 times, most recently from 1aa7326 to c9b2026 Compare July 10, 2025 07:35
@agrawroh agrawroh marked this pull request as ready for review July 10, 2025 08:44
@agrawroh agrawroh requested review from ggreenway and tyxia as code owners July 10, 2025 08:44
Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

Generally I agree this would be useful, but I wonder if this would come with a security implication. If the route-recalculating filter comes after this per-route ext_authz, then it can somehow bypass the authz for a specific route. For example, let's say we have two routes A and B and each one has its own authz server. When a request comes in, say, route A got selected. Then ext_authz filter does the auth logic for that route A. Then some filter after authz change clears the route cache and then changes the destination route to route B. That means the request bypasses the auth for route B by using auth for route A.

I am not saying that this would be common thing but i guess at least we should document this implication?

@agrawroh
Copy link
Member Author

Generally I agree this would be useful, but I wonder if this would come with a security implication. If the route-recalculating filter comes after this per-route ext_authz, then it can somehow bypass the authz for a specific route. For example, let's say we have two routes A and B and each one has its own authz server. When a request comes in, say, route A got selected. Then ext_authz filter does the auth logic for that route A. Then some filter after authz change clears the route cache and then changes the destination route to route B. That means the request bypasses the auth for route B by using auth for route A.

I am not saying that this would be common thing but i guess at least we should document this implication?

Thanks, @mathetake. It's a great point and I agree that we should document it.

The scenario you described also exists today as technically an incoming request can match on a Route A with per-route ExtAuthZ override to disable the filter, clear the route cache using LUA in a subsequent filter and make it match on a Route B which requires ExtAuthZ. Same risk of privilege escalation.

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
@agrawroh agrawroh force-pushed the ext-authz-cluster branch from c9b2026 to 465e6a6 Compare July 14, 2025 23:57
Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for this new feature. One comment to start the review.

Comment on lines +516 to +525

// Set a different gRPC service for this route than the default.
// This allows different routes to use different external authorization service backends.
//
// .. note::
//
// This setting is only applied to a filter configured with a
// :ref:`grpc_service<envoy_v3_api_field_extensions.filters.http.ext_authz.v3.ExtAuthz.grpc_service>`.
// If the filter is configured with an ``http_service``, this field is ignored.
config.core.v3.GrpcService grpc_service = 4;
Copy link
Member

Choose a reason for hiding this comment

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

Could we support http_service override here also? Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

@wbpcode Yes, i think we can support HTTP as well. We internally use gRPC and have this use-case so I started with gRPC first. I can create a follow-up for HTTP next if that sounds good.

Copy link
Member

Choose a reason for hiding this comment

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

I think the behavior may be unexpected? From you comment of API, the grpc_service will only override the filter level grpc_service. But we may expect it override any http_service or http_service?

@wbpcode
Copy link
Member

wbpcode commented Jul 15, 2025

/wait

Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and I add some comments to both API and the impl. :)

Comment on lines +516 to +525

// Set a different gRPC service for this route than the default.
// This allows different routes to use different external authorization service backends.
//
// .. note::
//
// This setting is only applied to a filter configured with a
// :ref:`grpc_service<envoy_v3_api_field_extensions.filters.http.ext_authz.v3.ExtAuthz.grpc_service>`.
// If the filter is configured with an ``http_service``, this field is ignored.
config.core.v3.GrpcService grpc_service = 4;
Copy link
Member

Choose a reason for hiding this comment

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

I think the behavior may be unexpected? From you comment of API, the grpc_service will only override the filter level grpc_service. But we may expect it override any http_service or http_service?

@agrawroh agrawroh requested a review from wbpcode August 1, 2025 04:41
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
@phlax
Copy link
Member

phlax commented Aug 5, 2025

@agrawroh needs main merge

looks like this will have to wait for further review from @wbpcode

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for your update. And some comments are added.

/lgtm api

@repokitteh-read-only repokitteh-read-only bot removed the api label Aug 7, 2025
@agrawroh agrawroh requested a review from wbpcode August 7, 2025 21:24
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Overall is fine. I actually have a thought, but up to you. May be we cann create a function to load the configuration (grpc_service, http_service, encode_raw_headers) then return a lambda. This lambda will create a client instance when it's executed. Then, the config and per route config could share the tool function.

That would make our code much simple to read and may have better performance because avoiding unnecessary copies (although doesn't matter because the network consume the largest time)

Comment on lines +250 to +252
// Create a temporary ExtAuthz config with the HTTP service for the ClientConfig constructor.
envoy::extensions::filters::http::ext_authz::v3::ExtAuthz temp_config;
temp_config.mutable_http_service()->CopyFrom(http_service);
Copy link
Member

Choose a reason for hiding this comment

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

I think maybe we should update the constructor of ClientConfig to accept HttpService only to avoid the this copy. But it's not in a hurry. The auth is slow anyway.

@wbpcode
Copy link
Member

wbpcode commented Aug 9, 2025

/wait

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@agrawroh agrawroh merged commit 8c03b2a into envoyproxy:main Aug 22, 2025
25 checks passed
@antoniovleonti
Copy link
Contributor

I'm seeing ext_authz_test failures on #40811 and #40650 that are not related to my PR, can you check if they're related to this change?

@antoniovleonti
Copy link
Contributor

The failing test is ParameterizedFilterConfig/HttpFilterTestParam.PerRouteConfigurationIntegrationTest/FailClosed_GrpcClient, gotta be related right?

phlax added a commit to phlax/envoy that referenced this pull request Aug 23, 2025
phlax added a commit to phlax/envoy that referenced this pull request Aug 23, 2025
…voyproxy#40169)"

This reverts commit 8c03b2a.

Signed-off-by: Ryan Northey <ryan@synca.io>
melginaldi pushed a commit to melginaldi/envoy that referenced this pull request Aug 26, 2025
…#40169)

## Description

This PR adds support for per-route gRPC service override in the
`ext_authz` HTTP filter, allowing different routes to use different
external authorization backends. Routes would now be able to specify a
different authorization service by configuring `grpc_service` in the
per-route `check_settings`.

---

Commit Message: ext_authz: add grpc_service field on the per-route
filter
Additional Description: Add a new `grpc_service` field on the per-route
ExtAuthZ filter to be able to override the AuthService backend on a
per-route basis.
Risk Level: Low
Testing: Added Unit & Integration Tests
Docs Changes: Added
Release Notes: Added

---------

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Signed-off-by: Melissa Ginaldi <mginaldi@google.com>
melginaldi pushed a commit to melginaldi/envoy that referenced this pull request Aug 26, 2025
…#40169)

## Description

This PR adds support for per-route gRPC service override in the
`ext_authz` HTTP filter, allowing different routes to use different
external authorization backends. Routes would now be able to specify a
different authorization service by configuring `grpc_service` in the
per-route `check_settings`.

---

Commit Message: ext_authz: add grpc_service field on the per-route
filter
Additional Description: Add a new `grpc_service` field on the per-route
ExtAuthZ filter to be able to override the AuthService backend on a
per-route basis.
Risk Level: Low
Testing: Added Unit & Integration Tests
Docs Changes: Added
Release Notes: Added

---------

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
Signed-off-by: Melissa Ginaldi <mginaldi@google.com>
wtzhang23 pushed a commit to wtzhang23/envoy that referenced this pull request Aug 27, 2025
…#40169)

## Description

This PR adds support for per-route gRPC service override in the
`ext_authz` HTTP filter, allowing different routes to use different
external authorization backends. Routes would now be able to specify a
different authorization service by configuring `grpc_service` in the
per-route `check_settings`.

---

Commit Message: ext_authz: add grpc_service field on the per-route
filter
Additional Description: Add a new `grpc_service` field on the per-route
ExtAuthZ filter to be able to override the AuthService backend on a
per-route basis.
Risk Level: Low
Testing: Added Unit & Integration Tests
Docs Changes: Added
Release Notes: Added

---------

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
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