Hello. I need help. I'm configuring Spring Security in a JSF 2.2 Project. Using Annotation. I've already set up the filters. But I do not understand how to configure the ManagedBean of the login to search the database and log in to JSF. Below is my Spring Security configuration class
@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 / **") ;; }
}
Important Remember I use Hibernate and a User Table. Thus. I want to query the user on the ManagedBean. and then start the session if it exists. Can anyone help me?