Redirecting to original (unauthenticated page) after spring security openid authentic
I have implemented spring security openid integration using the sample available here:http://static.springsource.org/sprin...mple-apps.html
The integration works fine. When I request a protected resource I get redirected to a login page and after authentication I'm automagically redirected to the protected resource.
However, if I am on an unprotected page ( similar to the situation described here: http://forum.springsource.org/showth...uccess-failure ) and I click on the login button..I get redirected to the homepage after login. I would like to be redirected to the page where I clicked the login button from.
The spring forum thread suggests overriding the buildReturnToUrl method. I have debugged thru it. It always generates a returnToURL of the form:
Code:
http://localhost:8080/listocal/j_spring_openid_security_check
There was some behind the scene communication between op and Rob Winch and I'm not sure how op actually overwrote it.
Alternatively, I have tried to create another filter with code like this:
Code:
public void doFilter(....) {
...
DefaultSavedRequest savedRequest = new DefaultSavedRequest((HttpServletRequest) request, new PortResolverImpl());
((HttpServletRequest)request).getSession().setAttribute("SPRING_SECURITY_SAVED_REQUEST", savedRequest);
}
If this filter runs before the OpenIDAuthenticationFilter then the savedrequest is removed by RequestCacheAwareFilter ( probably because of this issue: https://jira.springsource.org/browse/SEC-1241)
If this filter runs after OpenIDAuthenticationFilter then I do run into the issue where post parameters get concatenated after each request.
Can someone point out the right way forward on this?