Olá. Preciso de uma ajuda. Estou configurando o Spring Security em um Projeto JSF 2.2. Utilizando Annotation. Já consegui configurar os filtros. Mas não entendo como configurar o ManagedBean do login para buscar no banco de dados e fazer o login no JSF. Abaixo está minha classe de configuração do Spring Security
@Configuration
@EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("zezinho").password("123456").roles(Constantes.PERMISSAO_USER);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.antMatchers(Constantes.RESOURCES).permitAll()
.antMatchers(Constantes.PUBLIC + Constantes.URL_ALL).permitAll()
.antMatchers(Constantes.PRIVATE).hasRole(Constantes.PERMISSAO_USER).anyRequest().authenticated()
.and()
.formLogin()
.loginPage(Constantes.PAGE_PUBLIC_URL_LOGIN)
.successForwardUrl(Constantes.PAGE_PRIVATE_URL_PRINCIPAL)
.permitAll();
}
@Override
public void configure(WebSecurity web) throws Exception {
// web.ignoring().antMatchers("/resources/**");; }
}
Importante Lembrar Que utilizo o Hibernate e uma Tabela Usuário. Sendo assim. Quero fazer a consulta do usuário no ManagedBean. e depois iniciar a sessão caso exista. Alguém pode me ajudar?