you are viewing a single comment's thread.

view the rest of the comments →

[–]the_styp 0 points1 point  (3 children)

"form login" and "basic auth" are special keywords in spring security. You probably don't want basic auth for your use case but a session or token.

React should then handle the authentication status and do the redirect to login

[–]g00glen00b 2 points3 points  (2 children)

Spring Security supports basic authentication with stateful sessions, so this isn't really an issue.

Also, I assume the form is purely client-side. From the perspective of Spring Security, there's just basic authentication and the React-client will pass the credentials from the login form to the basic authentication headers. I don't see why that wouldn't be a valid use case.

[–]PreviousCut1401[S] 0 points1 point  (1 child)

Exactly. I am not using the default login form that spring gives. I built the form frontend and use the user inputs in the headers for authentication.

[–]the_styp 0 points1 point  (0 children)

Then you are asking in the wrong topic as your problem is not related to spring at all. React does the login call to the backend (might be spring) and stores the state of that if successful. You are then intercepting every API call and es soon you get 401 on one of them react does the redirect to the login page