Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring 3 Security Authentication Success Handler

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" />
like image 434
Eqbal Avatar asked Apr 29 '10 19:04

Eqbal


People also ask

How do I install AuthenticationSuccessHandler?

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.

What is AuthenticationManagerBuilder?

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.

How does Spring Security authentication work?

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.


1 Answers

Resuming of the initial request is implemented in the SavedRequestAwareAuthenticationSuccessHandler, which is used by default by <form-login>.

like image 177
axtavt Avatar answered Oct 27 '22 15:10

axtavt