两个角色的SecurityConfig

时间:2017-09-18 08:10:36

标签: java spring spring-mvc spring-security

我正在尝试使用Spring Security,所有人都使用过一个角色。

protected void configure(HttpSecurity http) throws Exception {
    http.formLogin().loginPage("/login");
    http.csrf().disable();

    http.authorizeRequests().antMatchers("/index","/","/ajouterFiliere").hasRole("RM");
    http.authorizeRequests().antMatchers("/index","/","/ajouterFiliere").hasRole("RF");

    http.exceptionHandling().accessDeniedPage("/403");

}

它的作用是一个角色而不是两个角色 请帮助我,谢谢你

1 个答案:

答案 0 :(得分:2)

尝试: http.authorizeRequests().antMatchers("/index","/","/ajouterFiliere").hasAnyRole("RM", "RF")

这应该有所帮助。

相关问题