Spring Security: как авторизоваться только при наличии роли АДМИН и определенных прав доступа?

Есть БД USERS с двумя пользователями, одному выдана роль ADMIN, а другому выдана роль ADMIN и READ_PROFILE.

Как новичку в Spring Security поясните, что необходимо сделать, чтобы при переходе на страницу "/read_profile/" доступ предоставлялся только пользователям, которые имеют роль ADMIN и права доступа read_profile?

В текущей реализации пользователь, которому выдана только роль ADMIN (без прав доступа read_profile) все равно спокойно заходит на страницу, вводя свой логин и пароль.

@EnableWebSecurity
@Order(1)
//@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private UserService userService;

@Autowired
public void setUserService(UserService userService) {
    this.userService = userService;
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
            .antMatchers("/authenticated/**").authenticated()
            .antMatchers("/read_profile/**").hasAuthority("READ_PROFILE")
            .antMatchers("/read_profile/**").hasRole("ADMIN")
            .and()
            .formLogin()
            .and()
            .logout().logoutSuccessUrl("/");
}




@Bean
public PasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
}

@Bean
public DaoAuthenticationProvider daoAuthenticationProvider() {
    DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
    authenticationProvider.setPasswordEncoder(passwordEncoder());
    authenticationProvider.setUserDetailsService(userService);
    return authenticationProvider;
}
}

Ответы (0 шт):