Skip to content

Fix EndpointRequest.toLinks() when base-path is '/'#49191

Closed
bbbbooo wants to merge 1 commit intospring-projects:mainfrom
bbbbooo:main
Closed

Fix EndpointRequest.toLinks() when base-path is '/'#49191
bbbbooo wants to merge 1 commit intospring-projects:mainfrom
bbbbooo:main

Conversation

@bbbbooo
Copy link

@bbbbooo bbbbooo commented Feb 11, 2026

Problem

When management.endpoints.web.base-path is set to /, it is normalized
to an empty path internally. In this setup, when management runs on a
different port, EndpointRequest.toLinks() never matches.

As a result, security configurations such as
EndpointRequest.toLinks().permitAll() do not work as expected.

This behavior is inconsistent with the actual links endpoint mapping.

Changes

  • Servlet:
    • Use the WebApplicationContext to determine the effective links path.
    • Create a links matcher for / when the management port is different
      and the base path is empty.
  • Reactive:
    • Apply the same links path behavior as the servlet stack.
  • Apply this consistently to:
    • EndpointRequest.toLinks()
    • EndpointRequest.toAnyEndpoint() (links inclusion path)

Tests

Added/updated tests for both servlet and reactive variants to cover:

  • toAnyEndpoint with an empty base path and a different management port
    (links should match)
  • toLinks with an empty base path and a different management port
    (root links matching)

Fixes #34834

When management.endpoints.web.base-path is empty and management runs
on a different port, EndpointRequest.toLinks() and toAnyEndpoint()
do not match the links endpoint consistently.

Derive the links path based on the management port type on both
servlet and reactive sides, and add regression tests for each
implementation.

Fixes spring-projects#34834

Signed-off-by: bbbbooo <hyeons1213@gmail.com>
@bbbbooo bbbbooo changed the title Fix EndpointRequest links matching for separate management port Fix EndpointRequest.toLinks() when base-path is '/' Feb 11, 2026
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 11, 2026
@wilkinsona wilkinsona changed the base branch from main to 3.5.x March 12, 2026 14:12
@wilkinsona wilkinsona changed the base branch from 3.5.x to main March 12, 2026 14:13
@wilkinsona
Copy link
Member

@bbbbooo thanks for the PR. Can you please update it to use a branch in your repository created specifically for these changes rather than making the contribution directly from main?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Mar 12, 2026
@bbbbooo bbbbooo closed this Mar 13, 2026
@bbbbooo
Copy link
Author

bbbbooo commented Mar 13, 2026

@bbbbooo thanks for the PR. Can you please update it to use a branch in your repository created specifically for these changes rather than making the contribution directly from main?

Thanks for the note. I moved the changes to a dedicated branch and opened a new PR from that branch. I’ll close this one.

@wilkinsona wilkinsona added status: superseded An issue that has been superseded by another and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Mar 13, 2026
@wilkinsona
Copy link
Member

Thanks.

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

Labels

status: superseded An issue that has been superseded by another

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EndpointRequest.toLinks() does not match when management.endpoints.web.base-path is '/'

3 participants