Olá!
Eu criei o perfil Instituição, porém está dando acesso negado, basicamente terá acesso ao cadastro também.
Pode dar o mesmo acesso a perfis diferentes?
Classe SecurityConfiguration:
package br.com.projeto.cuidandodaatencao.conf;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import br.com.projeto.cuidandodaatencao.dao.UsuarioDAO;
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private UsuarioDAO usuarioDao;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/alunos/form").hasRole("ADMIN")
.antMatchers("/alunos/CadastroAluno").hasRole("INSTITUICAO")
.antMatchers("/alunos/CadastroAluno").hasRole("ADMIN")
.antMatchers("/alunos/CadastroAluno").hasRole("INSTITUICAO")
.antMatchers("/alunos").hasRole("ADMIN")
.antMatchers("/alunos/**").permitAll()
.antMatchers("/resources/**").permitAll()
.antMatchers("/").permitAll()
.anyRequest().authenticated()
.and().formLogin().loginPage("/login").permitAll()
.and().logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"));
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(usuarioDao)
.passwordEncoder(new BCryptPasswordEncoder());
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/jquery/**");
}
}
Obrigada!