Quick revision
The short answer
WebSecurityConfigurerAdapter was deprecated in Spring Security 5.7 and removed in 6.0; instead we declare SecurityFilterChain beans that build HttpSecurity. antMatchers and mvcMatchers were replaced by requestMatchers, and authorizeRequests by authorizeHttpRequests, which is backed by AuthorizationManager. @EnableGlobalMethodSecurity became @EnableMethodSecurity, with @PreAuthorize and @PostAuthorize enabled by default. The lambda DSL is now the standard style: and() chaining was deprecated in 6.1 and is removed in Spring Security 7.
What to remember
In this answer, we saw how a Spring Security 5 configuration maps to version 6 and later. WebSecurityConfigurerAdapter, deprecated in 5.7 and removed in 6.0, becomes SecurityFilterChain beans; antMatchers and mvcMatchers become requestMatchers; authorizeRequests becomes authorizeHttpRequests, backed by AuthorizationManager, which also authorizes forward and error dispatches; @EnableGlobalMethodSecurity becomes @EnableMethodSecurity with the pre and post annotations on by default; and the lambda DSL replaces and() chaining, which is removed in Spring Security 7.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
WebSecurityConfigurerAdapter was deprecated in Spring Security 5.7 and removed in 6.0; instead we declare SecurityFilterChain beans that build HttpSecurity. antMatchers and mvcMatchers were replaced by requestMatchers, and authorizeRequests by authorizeHttpRequests, which is backed by AuthorizationManager. @EnableGlobalMethodSecurity became @EnableMethodSecurity, with @PreAuthorize and @PostAuthorize enabled by default. The lambda DSL is now the standard style: and() chaining was deprecated in 6.1 and is removed in Spring Security 7.
Why this question is asked
Many code bases still carry security configuration written for Spring Security 5, and it stops compiling the moment the application moves to Spring Boot 3 or 4. The changes are mostly mechanical, but they are not just renames: the new authorization model behaves differently in a few places, and that is where upgrades go wrong. Interviewers ask this to check that we know both the new names and the reasons behind them. In this answer, we will look at an old configuration, replace each piece in turn, explain what behaves differently, and finish with the method security and DSL changes.
1A Typical Spring Security 5 Configuration
Here is the kind of configuration many applications still have. It extends WebSecurityConfigurerAdapter, overrides configure(HttpSecurity), uses antMatchers and authorizeRequests, and chains sections with and().
2From the Adapter to SecurityFilterChain Beans
WebSecurityConfigurerAdapter was a base class we extended to customise one security setup by overriding methods. It made configurations hard to compose: only one class per chain, inheritance instead of beans, and hidden ordering rules. It was deprecated in 5.7 and removed in 6.0.
The replacement is a plain @Bean method that receives an HttpSecurity, configures it and returns http.build(), a SecurityFilterChain. Each bean is one filter chain; several beans with @Order and securityMatcher() replace several adapter subclasses. Related overrides moved too: what configure(WebSecurity) did for ignoring paths is a WebSecurityCustomizer bean, though permitAll() is usually better, and the AuthenticationManager is exposed through AuthenticationConfiguration or defined as a bean instead of overriding authenticationManagerBean().
Notice that @Configuration is written explicitly. Since 6.0, @EnableWebSecurity and @EnableMethodSecurity no longer include it, so a class with only those annotations is not picked up as configuration.
3From antMatchers to requestMatchers
antMatchers(), mvcMatchers() and regexMatchers() were separate methods for separate matching styles, and choosing the wrong one caused real vulnerabilities: antMatchers("/admin") did not match /admin/ or /admin.json in some setups, while Spring MVC would still route them to the controller. In 6.0 they were replaced by one method, requestMatchers(), which picks a suitable matcher for the application: with Spring MVC on the classpath it matches the way MVC does.
The exact matcher behind requestMatchers() has evolved. Recent versions use PathPatternRequestMatcher, the same path pattern syntax as Spring MVC's routing, and Spring Security 7 makes it the default. Most patterns like /admin/** behave the same; unusual patterns with regex-like segments may need adjusting, so check your version's migration guide.
4From authorizeRequests to authorizeHttpRequests
This change is more than a rename. authorizeRequests() was built on the old FilterSecurityInterceptor with AccessDecisionManager and voters. authorizeHttpRequests() is built on AuthorizationFilter and AuthorizationManager, a simpler interface with one decision method that returns a granted or denied result.
Two behaviours differ in practice. AuthorizationFilter applies to every dispatcher type by default, including FORWARD and ERROR dispatches, so internal forwards and the /error page are authorized too and may need explicit permitAll() rules. And the authentication is looked up lazily, only when a rule needs it, which saves work for permitAll() paths. Custom voters must be rewritten as AuthorizationManager implementations, and expression strings move to helpers such as hasRole() or WebExpressionAuthorizationManager.
| Old | New | Removed in |
|---|---|---|
WebSecurityConfigurerAdapter | SecurityFilterChain @Bean | 6.0 (deprecated 5.7) |
configure(WebSecurity) ignoring | WebSecurityCustomizer bean, prefer permitAll | 6.0 |
antMatchers, mvcMatchers, regexMatchers | requestMatchers | 6.0 |
authorizeRequests | authorizeHttpRequests (AuthorizationManager) | deprecated in 6.x; check 7 |
@EnableGlobalMethodSecurity | @EnableMethodSecurity | deprecated since 5.8; check 7 |
and() chaining | lambda DSL | 7.0 (deprecated 6.1) |
5Method Security and the Lambda DSL
@EnableGlobalMethodSecurity(prePostEnabled = true) becomes @EnableMethodSecurity. The new annotation enables @PreAuthorize, @PostAuthorize, @PreFilter and @PostFilter by default, so prePostEnabled no longer needs to be set; @Secured and the JSR-250 annotations still need securedEnabled = true or jsr250Enabled = true. Like URL authorization, it is built on AuthorizationManager and uses Spring AOP advisors directly rather than the old metadata sources.
The last change is style. The non-lambda style, with and() between sections, made it hard to see where one section ended and the next began, and configurers had to return the parent builder. The lambda DSL gives each section its own lambda, so nesting is visible and defaults are written as Customizer.withDefaults(). The old style was deprecated in 6.1 and is removed in 7, so moving to lambdas now is the cheapest step of the next upgrade.
6Follow-up questions
Can we migrate to the new style while still on Spring Security 5.8?
Yes, and that is the recommended path. 5.8 already has SecurityFilterChain beans, requestMatchers(), authorizeHttpRequests(), @EnableMethodSecurity and the lambda DSL, so we can change the configuration first, test it, and then upgrade the version with fewer moving parts.
We had two adapter subclasses with @Order. How do they map?
Each becomes a SecurityFilterChain bean method with the same @Order, and each must call securityMatcher() to say which requests it handles, since only the last chain may match everything. FilterChainProxy picks the first chain whose matcher fits.
What replaces a custom AccessDecisionVoter?
An AuthorizationManager<RequestAuthorizationContext> for URL rules, used with .access(manager), or an AuthorizationManager<MethodInvocation> for method security. The decision logic usually ports directly; the voting and abstaining machinery disappears.
7Conclusion
In this answer, we saw how a Spring Security 5 configuration maps to version 6 and later. WebSecurityConfigurerAdapter, deprecated in 5.7 and removed in 6.0, becomes SecurityFilterChain beans; antMatchers and mvcMatchers become requestMatchers; authorizeRequests becomes authorizeHttpRequests, backed by AuthorizationManager, which also authorizes forward and error dispatches; @EnableGlobalMethodSecurity becomes @EnableMethodSecurity with the pre and post annotations on by default; and the lambda DSL replaces and() chaining, which is removed in Spring Security 7.
Open with
There are five changes I'd mention. First, WebSecurityConfigurerAdapter was deprecated in 5.7 and removed in 6.0, so instead of extending a class and overriding configure, I declare SecurityFilterChain beans that take HttpSecurity and return http.build().
Then, if they want more
Several adapters with @Order become several beans with @Order and securityMatcher, and the ignoring config becomes a WebSecurityCustomizer, though permitAll is usually better. Also, @EnableWebSecurity no longer includes @Configuration, so I add it.
Second, antMatchers, mvcMatchers and regexMatchers are replaced by a single requestMatchers method, which matches the way Spring MVC routes, and in recent versions uses path patterns by default, so the old mismatch between security patterns and MVC routing goes away. Third, authorizeRequests became authorizeHttpRequests, built on AuthorizationFilter and AuthorizationManager instead of voters.
That one has behaviour changes: it authorizes all dispatcher types, so error and forward dispatches need rules, and custom voters become AuthorizationManagers. Fourth, @EnableGlobalMethodSecurity with prePostEnabled becomes @EnableMethodSecurity, where @PreAuthorize and @PostAuthorize are on by default, and @Secured needs securedEnabled. Fifth, the lambda DSL is the standard: and() chaining was deprecated in 6.1 and is removed in 7.
I'd do all of this on 5.8 first, since it supports the new style, and then bump the version.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Security 7, Spring Security 5, Spring Security 6, Spring Boot 3
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Security reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Your code base uses WebSecurityConfigurerAdapter, antMatchers and authorizeRequests....": https://scrivio-interview-library.netlify.app/spring-boot/security-architecture/f9065b0740/