Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change default-target-url depending on user role

I use spring security for user authentication. In security.xml I have

<form-login login-page="/login" 
                default-target-url="/dashboard" 
                always-use-default-target="false"  
                authentication-failure-url="/login/error" 
                login-processing-url="/j_security_check"/>

I want to be able to configure different target urls for different user roles. How do i do this?

Thanks!

like image 765
hese Avatar asked Jan 07 '11 20:01

hese


2 Answers

If you're using Spring-Security 3.0 or higher implementing your own AuthenticationSuccessHandler is the way to go:

<sec:form-login ... authentication-success-handler-ref="successHandler"/>
...
<bean id="successHandler" class="de.....MySpecialAuthenticationSuccessHandler">

Then MySpecialAuthenticationSuccessHandler can extend one of the default handlers like SavedRequestAwareAuthenticationSuccessHandler though they are not really inheritance-friendly.

like image 149
Robin Avatar answered Sep 19 '22 18:09

Robin


see -

http://forum.springsource.org/showthread.php?t=93541

like image 29
hese Avatar answered Sep 22 '22 18:09

hese