I have backend in spring-boot, exposing REST API, and i have SEPARATED front end in react.
I want to use spring security to secure my back end, and i want to keep spring authentication chain. However, when i use configuration such as:
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.addFilterBefore(authenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.cors().disable()
.csrf().disable()
.authorizeRequests()
.antMatchers("/newUser").permitAll()
.anyRequest().authenticated()
.and()
.exceptionHandling()
.and()
.formLogin().pertmitAll();
}
This generates /login endpoint and every request that is not authorized will get redirected to login page. However spring generates this /login login page and as i said i have my own stand-alone fornt-end in REACT, so i do not want spring to generate this page, i want it to tell my client to redirect to /login. If i disable formLogin
.formLogin().disable()
then i also lose my /login POST endpoint, and springs default authentication process.
Is there a way to keep to /login POST endpoint but remove the login page and let my frond-end client to redirect.
Thanks for help!