Skip to content

oauth2: per-route configuration#44235

Merged
wbpcode merged 33 commits into
envoyproxy:mainfrom
zhaohuabing:oauth2-per-route-config
Apr 9, 2026
Merged

oauth2: per-route configuration#44235
wbpcode merged 33 commits into
envoyproxy:mainfrom
zhaohuabing:oauth2-per-route-config

Conversation

@zhaohuabing
Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing commented Apr 2, 2026

Commit Message: This PR adds per-route support for the OAuth2 filter. The OAuth2 filter is used in Envoy Gateway’s SecurityPolicy. Previously, Envoy Gateway created a separate OAuth2 filter per route on the HCM listener chain to achieve per-route behavior, which caused listener drains on SecurityPolicy create/update/delete. This change enables native per-route configuration and reduces listener churn.

Additional Description:
Risk Level: low
Testing: the change is covered in unit tests, also manually verified with https://github.com/zhaohuabing/playground/tree/main/envoy/native-per-route-oauth2-oidc
Docs Changes: The OAuth2 docs
Release Notes: Yes
Platform Specific Features: No
[Optional Runtime guard:] No
[Optional Fixes #Issue] Fixes #29641
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:] No
[Optional API Considerations:]

@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: #44235 was opened by zhaohuabing.

see: more, trace.

@zhaohuabing zhaohuabing changed the title per-route oauth2 configuration oauth2: per-route configuration Apr 2, 2026
@zhaohuabing zhaohuabing force-pushed the oauth2-per-route-config branch from 5b6b4e6 to 4f3c568 Compare April 2, 2026 13:31
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

format

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

update

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

update

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

fix test

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

fix test

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

improve the test

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

fix test

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

fix test

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing force-pushed the oauth2-per-route-config branch 2 times, most recently from c72f773 to fbc27c6 Compare April 3, 2026 05:32
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing force-pushed the oauth2-per-route-config branch from fbc27c6 to 3bfa54c Compare April 3, 2026 05:47
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing marked this pull request as ready for review April 3, 2026 07:55
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing
Copy link
Copy Markdown
Member Author

/retest

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing
Copy link
Copy Markdown
Member Author

/retest

zhaohuabing and others added 3 commits April 8, 2026 10:02
Co-authored-by: code <wbphub@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing requested a review from wbpcode April 8, 2026 03:30
@zhaohuabing zhaohuabing force-pushed the oauth2-per-route-config branch from 0769628 to b577f23 Compare April 8, 2026 03:42
Comment thread source/extensions/filters/http/oauth2/filter.cc
@zhaohuabing
Copy link
Copy Markdown
Member Author

/retest

@zhaohuabing zhaohuabing requested a review from wbpcode April 8, 2026 04:40
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
wbpcode
wbpcode previously approved these changes Apr 8, 2026
Copy link
Copy Markdown
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.

@wbpcode wbpcode enabled auto-merge (squash) April 8, 2026 08:20
auto-merge was automatically disabled April 8, 2026 08:24

Head branch was pushed to by a user without write access

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing force-pushed the oauth2-per-route-config branch from 093d434 to 9840fdd Compare April 8, 2026 08:28
@zhaohuabing zhaohuabing requested a review from wbpcode April 8, 2026 08:29
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing requested a review from adisuissa April 8, 2026 11:43
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing force-pushed the oauth2-per-route-config branch from 9492657 to 85a4d9f Compare April 8, 2026 12:07
@zhaohuabing
Copy link
Copy Markdown
Member Author

/retest

@wbpcode wbpcode merged commit 1b19109 into envoyproxy:main Apr 9, 2026
30 checks passed
nshipilov pushed a commit to nshipilov/envoy that referenced this pull request Apr 13, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: This PR adds per-route support for the OAuth2 filter.
The OAuth2 filter is used in Envoy Gateway’s SecurityPolicy. Previously,
Envoy Gateway created a separate OAuth2 filter per route on the HCM
listener chain to achieve per-route behavior, which caused listener
drains on SecurityPolicy create/update/delete. This change enables
native per-route configuration and reduces listener churn.

Additional Description:
Risk Level: low
Testing: the change is covered in unit tests, also manually verified
with
https://github.com/zhaohuabing/playground/tree/main/envoy/native-per-route-oauth2-oidc
Docs Changes: The OAuth2 docs
Release Notes: Yes
Platform Specific Features: No
[Optional Runtime guard:] No
[Optional Fixes #Issue] Fixes envoyproxy#29641
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:] No
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

---------

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: code <wbphub@gmail.com>
Signed-off-by: Nick Shipilov <nick.shipilov.n@gmail.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: This PR adds per-route support for the OAuth2 filter.
The OAuth2 filter is used in Envoy Gateway’s SecurityPolicy. Previously,
Envoy Gateway created a separate OAuth2 filter per route on the HCM
listener chain to achieve per-route behavior, which caused listener
drains on SecurityPolicy create/update/delete. This change enables
native per-route configuration and reduces listener churn.

Additional Description:
Risk Level: low
Testing: the change is covered in unit tests, also manually verified
with
https://github.com/zhaohuabing/playground/tree/main/envoy/native-per-route-oauth2-oidc
Docs Changes: The OAuth2 docs
Release Notes: Yes
Platform Specific Features: No
[Optional Runtime guard:] No
[Optional Fixes #Issue] Fixes envoyproxy#29641
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:] No
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

---------

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: code <wbphub@gmail.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.

oauth2 filter support per-route configuration

4 participants