spring-projects / spring-projects/spring-security

Add Instructions Detailing Servlet Path Declaration in Migration Guides

Open
#17,811 1 comment 0 reactions 1 assignee View on GitHub

@jzheaux is already working on this.

Since Aug 27, 2025.

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

Description

https://docs.spring.io/spring-security/reference/migration-7/web.html#_include_the_servlet_path_prefix_in_authorization_rules is intended to alert applications that they need to now specify the servlet path in each authorization URI pattern.

It does not describe that Security supports configuring a global servlet path by publishing your own PathPatternRequestMatcher.Builder bean:

@Bean
PathPatternRequestMatcher.Builder requestMatcherBuilder(PathPatternParser mvcPatternParser, DispatcherServletPath servletPath) {
	PathPatternRequestMatcher.Builder builder = new PathPatternRequestMatcher.withPathPatternParser(mvcPatternParser);
	String path = servletPath.getPath();
	return ("/".equals(path)) ? builder : builder.basePath(path);
}

The migration guide should be updated to demonstrate and explain this.

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.