Alex Rivera | Logout

Redirect after login (Spring security on GAE)

Asked 2011-03-01T17:16:06.700
12

I am having some troubles making my login redirect to the same place always. I have done something like this

<http auto-config="true" use-expressions="true" entry-point-ref="gaeEntryPoint" >
    <intercept-url pattern="/_ah/login" access="permitAll"/>
    <intercept-url pattern="/**" access="isAuthenticated()"/>
    <custom-filter position="PRE_AUTH_FILTER" ref="gaeFilter"/>
    <form-login authentication-success-handler-ref="authSuccessHandler"/>
</http>

<beans:bean id="authSuccessHandler"
            class="dk.lindhardt.arbejdsfordeling.server.security.AuthenticationSuccessHandlerImpl"/>

And

public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler {

   public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) 
   throws IOException, ServletException {
       if (authentication != null && authentication.isAuthenticated()) {
           response.sendRedirect(OrganizationListServlet.URL);
       }
   }

 }

It never gets into this method above. How do I make it do that?

Edit: I was following this guide http://blog.springsource.com/2010/08/02/spring-security-in-google-app-engine/

Edit
Report

1 Answer

5

You could do it without the Handler by adding the "always-use-default-target" to your form-login settings

<form-login default-target-url='/your/target/url.htm' always-use-default-target='true' />

See http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#ns-form-and-basic under "Setting a Default Post-Login Destination"

answered 2011-03-01T17:26:49.170

Your Answer