In the official documentation of Spring Security 6.0.0 have an deprecated example:

  • https://docs.spring.io/spring-security/site/docs/6.0.0-SNAPSHOT/api/org/springframework/security/config/annotation/web/builders/HttpSecurity.html#authorizeRequests()
@Configuration
 @EnableWebSecurity
 public class AuthorizeUrlsSecurityConfig extends WebSecurityConfigurerAdapter {

        @Override
        protected void configure(HttpSecurity http) throws Exception {
                http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin();
        }

        @Override
        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
                auth.inMemoryAuthentication().withUser("user").password("password").roles("USER")
                                .and().withUser("admin").password("password").roles("ADMIN", "USER");
        }
 }

But WebSecurityConfigurerAdapter is deprecated. The documentation has outdated examples, it should have recommended examples for this version.

Comment From: sjohnr

@yhojann-cl thanks for trying 6.0 and welcome to the project! This is a duplicate of gh-11288 so I'll go ahead and close this as a duplicate.