I'm using Spring 3.0 along with Spring Security. I've always used the following configuration:
<form-login login-page="/login" authentication-failure-url="/login?error=credentials" default-target-url="/account" login-processing-url="/security_check"/>
So when the user doesn't login correctly, they go to /login. Now I have a login dialog on every page of the site. If they don't login correctly, I don't want them redirecting to /login.. instead I want them returning to the page they are at. I'll them popup that same dialog when I see the error=credentials as a parameter.
So how do I do this?
<!-- redirect url for failure of authentication -->
<bean id="simpleUrlAuthenticationFailureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<constructor-arg value="/login.jsp?error=1"></constructor-arg>
</bean>
I would suggest getting access to the object from the context and resetting the url OR writing your own custom handler which might perform actions specific to the page you are on
http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/web/authentication/SimpleUrlAuthenticationFailureHandler.html
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