@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().and().headers().and().anonymous().disable()
.formLogin().loginPage("/login.html").failureHandler(this.authenticationFailureHandler)
.defaultSuccessUrl("/main").loginProcessingUrl("/j_spring_security_check")
.usernameParameter("j_username").passwordParameter("j_password")
.and()
.logout().logoutUrl("/j_spring_security_logout").logoutSuccessUrl("/login.html");
}
Asked
Active
Viewed 71 times
-1

ankit giri
- 388
- 3
- 11
-
you mention basic auth but have configured form login. So which is it basic auth or form based login. – M. Deinum Jul 14 '21 at 08:00
-
@M.Deinum form auth – ankit giri Jul 14 '21 at 08:10
-
You need a `permitAll()` after the `passwordParemeter` to allow access else everything will be secured. You get a 403 which means you don't have access so either you aren't allowed to access that URL or to whatever you are being forwarded/redirected to . – M. Deinum Jul 14 '21 at 08:26
-
@M.Deinum added but still getting same error – ankit giri Jul 14 '21 at 08:46
-
im pretty sure `j_spring_security_check` is deprecated and removed the default login url is a POST to /login with username and password as form parameters – Toerktumlare Jul 14 '21 at 10:16
-
@Toerktumlare I changed it to /login but even then am getting same error – ankit giri Jul 14 '21 at 10:29
1 Answers
0
Add this in your security config class .authorizeRequests().antMatchers("/login*").permitAll()
Remove the following and().headers().and().anonymous()
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.formLogin().loginPage("/login.html").failureHandler(this.authenticationFailureHandler)
.defaultSuccessUrl("/main").loginProcessingUrl("/j_spring_security_check")
.usernameParameter("j_username").passwordParameter("j_password")
.and()
.logout().logoutUrl("/j_spring_security_logout").logoutSuccessUrl("/login.html");
}

ankit giri
- 388
- 3
- 11