Skip to content

EndpointRequest links matcher unnecessarily matches HTTP methods other than GET #50095

Open
dlwldnjs1009 wants to merge 2 commits intospring-projects:3.5.xfrom
dlwldnjs1009:fix-endpointrequest-links-httpmethod
Open

EndpointRequest links matcher unnecessarily matches HTTP methods other than GET #50095
dlwldnjs1009 wants to merge 2 commits intospring-projects:3.5.xfrom
dlwldnjs1009:fix-endpointrequest-links-httpmethod

Conversation

@dlwldnjs1009
Copy link
Copy Markdown
Contributor

@dlwldnjs1009 dlwldnjs1009 commented Apr 17, 2026

Summary

  • Hardcode the links matcher to GET (per the team decision in this PR's discussion).
  • Document the behaviour on EndpointServerWebExchangeMatcher.withHttpMethod(...) and EndpointRequestMatcher.withHttpMethod(...).

Test plan

  • toAnyEndpointWithHttpMethodShouldUseGetForLinks (servlet + reactive)
  • toLinksShouldOnlyMatchLinks strengthened with explicit GET/POST assertions

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 17, 2026
@wilkinsona
Copy link
Copy Markdown
Member

Thanks, @dlwldnjs1009. The links endpoint only supports GET requests but this certainly doesn't do any harm.

@wilkinsona wilkinsona added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 17, 2026
@wilkinsona wilkinsona added this to the 3.5.x milestone Apr 17, 2026
@dlwldnjs1009
Copy link
Copy Markdown
Contributor Author

Thanks, @dlwldnjs1009. The links endpoint only supports GET requests but this certainly doesn't do any harm.

Thanks for the clarification.

@wilkinsona wilkinsona self-assigned this Apr 17, 2026
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
@wilkinsona wilkinsona changed the base branch from main to 3.5.x April 17, 2026 13:22
@wilkinsona wilkinsona force-pushed the fix-endpointrequest-links-httpmethod branch from 097cde1 to 24f6214 Compare April 17, 2026 13:22
@wilkinsona
Copy link
Copy Markdown
Member

With the proposed change, you can configure the HTTP method for links when using toAnyEndpoint() but not when using toLinks(). That doesn't feel quite right. I'm wondering if we should just hardcode GET and document that's what happens. I'll discuss it with the team.

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Apr 17, 2026
@dlwldnjs1009
Copy link
Copy Markdown
Contributor Author

dlwldnjs1009 commented Apr 17, 2026

Thanks for the clarification. That makes sense. I'm happy to revise the PR to take that approach.

nikitanagar08 added a commit to nikitanagar08/spring-boot that referenced this pull request Apr 19, 2026
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.
@nikitanagar08

This comment was marked as resolved.

@wilkinsona

This comment was marked as resolved.

@philwebb philwebb added type: bug A general bug and removed type: task A general task for: team-meeting An issue we'd like to discuss as a team to make progress labels Apr 27, 2026
@wilkinsona
Copy link
Copy Markdown
Member

I'm happy to revise the PR to take that approach.

Thanks. We discussed this today and would like to go for the hardcoded GET approach. If you could update the PR, that would be much appreciated.

@philwebb philwebb changed the title Restrict EndpointRequest links to the specified HTTP method EndpointRequest links security matcher is too broad Apr 27, 2026
@philwebb philwebb changed the title EndpointRequest links security matcher is too broad EndpointRequest links matcher is too broad Apr 27, 2026
@philwebb philwebb changed the title EndpointRequest links matcher is too broad EndpointRequest links matcher unnecessarily matches HTTP methods other than GET Apr 27, 2026
@dlwldnjs1009
Copy link
Copy Markdown
Contributor Author

Done — pushed in af73d02. Updated the PR description to reflect the hardcoded GET direction.

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>
@dlwldnjs1009 dlwldnjs1009 force-pushed the fix-endpointrequest-links-httpmethod branch from af73d02 to 308de07 Compare April 28, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants