Skip to content

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

Merged
wilkinsona merged 2 commits intospring-projects:3.5.xfrom
bbbbooo:fix-endpointrequest-to-links
Mar 16, 2026
Merged

Fix EndpointRequest.toLinks() when base-path is '/'#49591
wilkinsona merged 2 commits intospring-projects:3.5.xfrom
bbbbooo:fix-endpointrequest-to-links

Conversation

@bbbbooo
Copy link
Contributor

@bbbbooo bbbbooo commented Mar 13, 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.

See spring-projectsgh-49591

Signed-off-by: bbbbooo <hyeons1213@gmail.com>
@wilkinsona wilkinsona changed the base branch from main to 3.5.x March 16, 2026 17:44
@wilkinsona wilkinsona force-pushed the fix-endpointrequest-to-links branch from 1d0bb9c to c039ca8 Compare March 16, 2026 17:44
See spring-projectsgh-49591

Signed-off-by: Andy Wilkinson <andy.wilkinson@broadcom.com>
@wilkinsona wilkinsona force-pushed the fix-endpointrequest-to-links branch from c039ca8 to a148983 Compare March 16, 2026 17:45
@wilkinsona wilkinsona added this to the 3.5.x milestone Mar 16, 2026
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 16, 2026
@wilkinsona wilkinsona modified the milestones: 3.5.x, 3.5.12 Mar 16, 2026
@wilkinsona wilkinsona merged commit 22e3646 into spring-projects:3.5.x Mar 16, 2026
1 check passed
@wilkinsona
Copy link
Member

Thanks very much, @bbbbooo.

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.

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

3 participants