Faced the following problem. I want to implement the display of all pages for non-authorized users except the accaunt page. It does not work, please tell me. Displays all pages, and there is no lock on the accaunt page.
@Configuration @EnableWebSecurity public class ConfigSecurity extends WebSecurityConfigurerAdapter{ // @Bean // public UserDetailsService userDetailsService() { // InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); // manager.createUser(User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build()); // return manager; // } @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser("user").password("user").roles("USER"); auth.inMemoryAuthentication().withUser("admin").password("admin").roles("ADMIN"); auth.inMemoryAuthentication().withUser("superadmin").password("superadmin").roles("SUPERADMIN"); } @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.authorizeRequests() .antMatchers("/**").permitAll() .antMatchers("/resources/**").permitAll() .antMatchers("/accaunt").access("hasRole('ROLE_USER')") .antMatchers("/admin").access("hasRole('ROLE_SUPERADMIN')") .anyRequest().authenticated() .and() .formLogin().defaultSuccessUrl("/", false) // .loginPage("/login") .permitAll() .and() .logout() .permitAll(); } }