I'm have a problem with Primefaces CommandButton action not being invoked with Spring Security. Without Spring Security is OK. I don't understand why. Can you help me?
I use Primefaces 5.2. and Spring Security 4.0.2.
I have a managed bean
@Getter
@Setter
@ManagedBean
@ViewScoped
public class LoginController implements Serializable {
private static final long serialVersionUID = 1L;
private String userName = "admin";
private String password = "123";
public void doLogin() {
System.out.println("test");
}
}
And login page with
<p:commandButton value="Войти в систему" action="#{loginController.doLogin()}" />
My Spring Security config
@Configuration
@EnableWebSecurity
public class SpringSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
http
.authorizeRequests()
.antMatchers("/javax.faces.resource/**").permitAll()
.antMatchers("/**").access("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
.antMatchers("/admin/**").access("hasRole('ROLE_ADMIN')")
.and()
.formLogin()
.loginPage("/pages/security/login.xhtml")
.permitAll()
.and()
.logout()
.logoutSuccessUrl("/pages/security/login.xhtml?logout")
.permitAll();
}
}