I want to prohibit going to pages / admin / ** except for users with ADMIN roles, and / user / ** only for USER. I read a bunch of manuals but did not understand what should be added:
@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserDetailsServiceImpl userDetailsService; @Autowired public void registerGlobalAuthentication(AuthenticationManagerBuilder auth) throws Exception { auth .userDetailsService(userDetailsService) .passwordEncoder(getShaPasswordEncoder()); } @Override protected void configure(HttpSecurity http) throws Exception { http.csrf() .disable() .authorizeRequests() .antMatchers("/resources/**", "/**").permitAll() .anyRequest().permitAll() .and(); http.formLogin() .loginPage("/login") .loginProcessingUrl("/j_spring_security_check") .failureUrl("/login?error") .usernameParameter("j_username") .passwordParameter("j_password") .permitAll(); http.logout() .permitAll() .logoutUrl("/logout") .logoutSuccessUrl("/login?logout") .invalidateHttpSession(true); }