Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing spring security logout-success-url programmatically

I need to redirect the user to 2 different logout urls based on his role. How do i go about doing this?

i am using spring security 2.0 and my xml looks something like this:

    <s:http access-denied-page="/" >
        <s:intercept-url pattern="/pages/SplashPage.jsf" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
        <s:intercept-url pattern="/pages/Home.jsf" access="ROLE_USER,ROLE_MERCHANT"/>

        <s:anonymous/>
        <s:form-login
            login-page="/"
            login-processing-url="/j_spring_security_check"
            default-target-url="/pages/Home.jsf"
            authentication-failure-url="/" always-use-default-target='false' />
        <s:logout invalidate-session="true" logout-url="/pages/logout.jsf" logout-success-url="/" />
        <s:concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="false"/>
    </s:http>
like image 635
mkoryak Avatar asked Nov 05 '22 02:11

mkoryak


1 Answers

I couldnt find any right way to do this, so i ended up with a hack:

  1. dont invalidate-session
  2. change the logout-success-url to special redirect controller
  3. in that controller, pull the user session to tell the user type
  4. invalidate the session
  5. redirect to proper url for the usertype
like image 132
mkoryak Avatar answered Nov 13 '22 05:11

mkoryak