I was reading many tutorials and none of them is working for me…
I use Spring 3.1.x with Spring Security. I have a bunch of secured url and many unsecured. Now, when the user is logged in and tries to logout I want him to stay in the same page as he was before so I use this:
<beans:bean id="logoutSuccessHandler" class="org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler">
<beans:property name="useReferer" value="true"/>
</beans:bean>
This works fine, however when the user logs out from the secured page it redirects him to the login page, and I would like to redirect to home page.. How can I achieve this?
Thanks in advance!
Since you have custom logic for redirecting, you need a custom
LogoutSuccessHandler.In this handler, you need to add this logic:
In your
requiresAuthentication()method, you need to use some part of Spring Security that determined if the URL needs authentication.You can use a
WebInvocationPrivilegeEvaluatorreference there. You get a hold of it through Spring through autowiring by class (since there will be a bean implementingWebInvocationPrivilegeEvaluator).The evaluator has a method that you can use,
isAllowed(uri, authentication).