EndpointRequest links matcher unnecessarily matches HTTP methods other than GET #50095
EndpointRequest links matcher unnecessarily matches HTTP methods other than GET #50095dlwldnjs1009 wants to merge 2 commits intospring-projects:3.5.xfrom
Conversation
|
Thanks, @dlwldnjs1009. The links endpoint only supports |
Thanks for the clarification. |
EndpointRequest.toAnyEndpoint().withHttpMethod(...) restricted endpoint paths but still allowed any HTTP method for the links path, yet the mappings for the links path are only registered for GET requests. Restrict the links path using the configured HttpMethod in both servlet and reactive matchers. Signed-off-by: Lee JiWon <dlwldnjs1009@gmail.com> See spring-projectsgh-50095
097cde1 to
24f6214
Compare
|
With the proposed change, you can configure the HTTP method for links when using |
|
Thanks for the clarification. That makes sense. I'm happy to revise the PR to take that approach. |
Fixes spring-projectsgh-50095 EndpointRequest.toAnyEndpoint().withHttpMethod() now applies the configured HTTP method to the links path in addition to endpoint paths. Previously, calling toAnyEndpoint().withHttpMethod(POST) restricted endpoint paths to POST but the links path (/actuator and /actuator/) still matched any HTTP method. Changes: - Updated getLinksMatchers() to accept and use httpMethod parameter - Modified LinksServerWebExchangeMatcher to accept httpMethod in constructor - Strengthened tests to verify links path respects configured HTTP method - Both servlet and reactive implementations updated The toLinks() matcher continues to accept any HTTP method to maintain backward compatibility.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Thanks. We discussed this today and would like to go for the hardcoded |
|
Done — pushed in af73d02. Updated the PR description to reflect the hardcoded |
The links endpoint only supports GET, so its matcher is now hardcoded to GET. withHttpMethod(...) continues to apply only to endpoint paths and the behaviour is documented on its Javadoc. Signed-off-by: Lee JiWon <dlwldnjs1009@gmail.com>
af73d02 to
308de07
Compare
Summary
GET(per the team decision in this PR's discussion).EndpointServerWebExchangeMatcher.withHttpMethod(...)andEndpointRequestMatcher.withHttpMethod(...).Test plan
toAnyEndpointWithHttpMethodShouldUseGetForLinks(servlet + reactive)toLinksShouldOnlyMatchLinksstrengthened with explicitGET/POSTassertions