'Add Spring security authentication to React
I have a project with built-in spring security athentication that works fine. Now I'm rewriting the frontend from jsp to react and I need authentication to work for both of them for now. So, if credentials is correct, spring returns my jsp index.jsp page, otherwise error.jsp page.
How can i apply this logic to react?
My configuration:
<sec:http auto-config="true" use-expressions="true" access-decision-manager-ref="accessDecisionManager">
<sec:intercept-url pattern="/login" access="permitAll"/>
<sec:intercept-url pattern="/test-alive/*permitted/**" access="permitAll"/>
<sec:intercept-url pattern="/pinChanged" access="permitAll"/>
<sec:intercept-url pattern="/changePassword" access="permitAll"/>
<sec:intercept-url pattern="/**" access="isAuthenticated()"/>
<sec:form-login login-page="/login"
authentication-success-handler-ref="loginSuccessHandler"
authentication-failure-handler-ref="loginFailedHandler"
authentication-details-source-ref="rsaDetailsSource"
/>
<sec:logout logout-url="/logout" invalidate-session="true" success-handler-ref="logoutSuccessHandler"/>
<sec:csrf request-matcher-ref="csrfSecurityRequestMatcher" token-repository-ref="tokenRepository"/>
<sec:session-management>
<sec:concurrency-control session-registry-ref="sessionRegistry"/>
</sec:session-management>
<sec:access-denied-handler error-page="/access-denied"/>
</sec:http>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
