2017-09-18 1 views
0

J'essaie d'utiliser Spring Security, tout a fonctionné avec un rôle.SecurityConfig pour deux rôles

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"); 

} 

ses œuvres pour un rôle non pour deux rôle s'il vous plaît me aider et merci

+1

Bien sûr, cela ne fonctionnera pas. Ajoutez simplement les rôles autorisés à 'hasRole' au lieu d'ajouter plusieurs lignes. Seul le premier correspond (car cela correspond à l'URL). –

Répondre

1

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

Cela devrait aider.