java - Cannot login with custom loginProcessingUrl -
i'm building rest service spring , using spring security. default solution loginform doesn't pass me. here it's websecurityconfig:
public class websecurityconfig extends websecurityconfigureradapter { class postauthsuccesshandler implements authenticationsuccesshandler { @override public void onauthenticationsuccess(httpservletrequest httpservletrequest, httpservletresponse httpservletresponse, authentication authentication) throws ioexception, servletexception { httpservletresponse.setstatus(200); } } class postauthfailurehandler implements authenticationfailurehandler { @override public void onauthenticationfailure(httpservletrequest httpservletrequest, httpservletresponse httpservletresponse, authenticationexception e) throws ioexception, servletexception { httpservletresponse.setstatus(403); e.printstacktrace(new printwriter(httpservletresponse.getoutputstream())); } } @autowired private mysqluserdetailsmanager mysqluserdetailsmanager; @override protected void configure(httpsecurity http) throws exception { http .authorizerequests() .antmatchers("/login", "/registration", "/checkuser", "/").permitall() .anyrequest().authenticated() .and().formlogin() .loginprocessingurl("/login") .successhandler(new postauthsuccesshandler()) .failurehandler(new postauthfailurehandler()) .permitall() .and().logout() .permitall() .and().exceptionhandling() .authenticationentrypoint(new http403forbiddenentrypoint()); } @override public void configure(websecurity web) throws exception { web.ignoring().antmatchers("/scripts/**"); web.ignoring().antmatchers("/styles/**"); web.ignoring().antmatchers("/jquery-validate/**"); web.ignoring().antmatchers("/bootstrap-3.3.6/**"); } @autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { auth.userdetailsservice(mysqluserdetailsmanager); } }
but /login request 403 forbidden. i'm understanding, redirect me /error. upd: pages responding 403 forbidden, "/","/checkuser".
i forget, in standard form there csrf key in hidden input. so:
http .csrf().disable()
Comments
Post a Comment