I am using form-login
for security and I am trying to implement an authentication success handler, but I am not sure how to go back to the resource that was initially requested before the login process. By default I think it implements a SimpleUrlAuthenticationSuccessHandler
and I tried to mirror that class implementation. But it sets a setDefaultTargetUrl(defaultTargetUrl)
and perhaps thats where the magic happens that it remembers the resource to go back to after the login process.
Any help is greatly appreciated. Below is my spring security <form-login/>
element
<form-login login-page="/login.jsp" login-processing-url="/b2broe_login"
authentication-success-handler-ref="passwordExpiredHandler"
authentication-failure-url="/login.jsp?loginfailed=true" />
Modify you applicationContext.In your applicationContext. xml, create a new bean containing our Custom AuthenticationSuccessHandler class. Next, add our custom authenticationsuccesshandler bean to our form login or create a new form login entity if you don't have one. form login is part of the http filter.
AuthenticationManagerBuilder is a helper class that eases the set up of UserDetailService, AuthenticationProvider, and other dependencies to build an AuthenticationManager. For a global AuthenticationManager, we should define an AuthenticationManager as a bean.
The Spring Security Architecture There are multiple filters in spring security out of which one is the Authentication Filter, which initiates the process of authentication. Once the request passes through the authentication filter, the credentials of the user are stored in the Authentication object.
Resuming of the initial request is implemented in the SavedRequestAwareAuthenticationSuccessHandler
, which is used by default by <form-login>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With