Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Use merged request attributes in ServletOAuth2AuthorizedClientExchangeFilterFunction - #20176

Draft
jay23606 wants to merge 1 commit into
spring-projects:mainfrom
jay23606:pr-go-simple/17379
Draft

jay23606 wants to merge 1 commit into
spring-projects:mainfrom
jay23606:pr-go-simple/17379

Conversation

@jay23606

Copy link
Copy Markdown

Fixes #17379.

ServletOAuth2AuthorizedClientExchangeFilterFunction.filter() merges the HttpServletRequest, HttpServletResponse and Authentication from the Reactor context into a request, but it then built the bearer request and the fallback exchange from the original request. When the filter is added with WebClient.Builder.filter() instead of oauth2Configuration(), the attributes exist only in the context, so the AuthorizationFailureForwarder saw a request with no servlet request/response and could not remove the authorized client on a 401/403 response.

The fix merges the request once at the start of filter() and runs the rest of the pipeline on the merged request. Behavior is otherwise unchanged.

Added regression test filterWhenUnauthorizedAndServletAttributesFromContextThenInvokeFailureHandlerWithServletAttributes, which supplies the servlet attributes only through the Reactor context and asserts the failure handler receives them.

Tests: not run locally (no dependency installation was allowed here). CI should run the oauth2-client module tests, in particular ServletOAuth2AuthorizedClientExchangeFilterFunctionTests and ServletOAuth2AuthorizedClientExchangeFilterFunctionITests.

Tests not run here: Gradle test run for the oauth2-client module (ServletOAuth2AuthorizedClientExchangeFilterFunctionTests and ITests) — not run locally because the rules forbid installing dependencies here; CI runs them.

Fixes #17379

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 26, 2026
…tExchangeFilterFunction

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>

This branch has not been deployed

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

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth2: ServletOAuth2AuthorizedClientExchangeFilterFunction can fail to remove client if webclient receives retryable responses.

2 participants