getting the url in the case of an auth failure
In grails acegi plugin, you can specify the authenticationFailureUrl property in SecurityConfig.
Is there a way to get the url that caused the auth failure in the scope of th开发者_如何学Pythone authenticationFailureUrl?
This is not as simple as just getting the request or looking on the params. If there is an auth failure, you get redirected to the authenticationFailureUrl, so the url on the request at that point is the authenticationFailureUrl, not the url that caused the auth failure.
Im my case, I set authenticationFailureUrl to be a controller method -- looking at everything in the debugger no solution is obvious to me....
Thanx in advance.
The SavedRequest
representing the original request is stored as a session attribute with name specified by the constant DefaultSavedRequest.SPRING_SECURITY_SAVED_REQUEST_KEY
(or AbstractProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY
in pre-3.0 versions).
This may help for others working with Spring Security 3.0.0 . In SS 3.0.3
AbstractProcessingFilter
is deprecated and there is no constant SPRING_SECURITY_SAVED_REQUEST_KEY
in DefaultSavedRequest
. So you can get this by:
SavedRequest savedRequest = (SavedRequest) session.getAttribute(WebAttributes.SAVED_REQUEST);
Reference : Spring Security: How to get the initial target url
精彩评论