spring-projects / spring-projects/spring-security

PathPatternRequestMatcher is not a suitable replacement for the deprecated MvcRequestMatcher

Open
#17,808 6 comments 2 reactions 1 assignee View on GitHub

@jzheaux is already working on this.

Since Aug 26, 2025.

in: web status: feedback-provided type: bug
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Describe the bug
Due to the deprecation of MvcRequestMatcher, its replacement 'PathPatternRequestMatcher' requires to know the servlet path(s) beforehand. In my usecase i cannot know this.

To Reproduce

  1. Have the security chain defined in a seperate autoconfigure module. With a permitAll path.
  2. Have a servlet path defined in the application that uses the autoconfigure module.
  3. In the old (mvcrequestmatcher) situation: request /servlet-path/permit-all-path = 200
  4. In the new (pathpatternrequestmatcher) situation: request /servlet-path/permit-all-path = Err

Expected behavior
Another matcher that can dynamically add the requestMatchers to each registered servlet within the applcation, without requiring me to know the servlet paths beforehand.

Sample

See a sample in this repo: https://github.com/genie137/demo-depr-webmvc-matcher
I have taken the important parts from closed source libraries to reproduce.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.