So I am trying to creating simple Login Page with help of the Spring Boot and Security. So what I currently have is custom login page and in memory authentication with one user and role. The problem is that when I am entering proper user/password spirng is not authenticating it as valid data, and redirecting me again to login page, but this time with: /login#error
On client side I am using thymeleaf.
form snippet:
Configuration class:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()//
.withUser("root").password("root").roles("USER");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests() //
.antMatchers("/").hasRole("USER") //
.antMatchers("/login*").permitAll().and() //
.formLogin() //
.loginPage("/login")//
.loginProcessingUrl("/perform_login")//
.and()//
.logout()//
.permitAll();
}
}
And controller is simple
@Controller
@RequestMapping("/login")
public class LoginController {
@GetMapping
public String getLoginPage() {
return "login";
}
}
Any idea what I am doing wrong?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)