você pode criar um SuccessHandler customizado.
public class CustomSuccessLoginHandler extends SavedRequestAwareAuthenticationSuccessHandler {
private RequestCache requestCache = new HttpSessionRequestCache();
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
SavedRequest savedRequest = requestCache.getRequest(request, response);
if(savedRequest==null || savedRequest.getRedirectUrl().contains("logout")){
response.sendRedirect("/urlDeSucesso");
} else {
super.onAuthenticationSuccess(request, response, authentication);
}
}
@Override
public void setRequestCache(RequestCache requestCache) {
super.setRequestCache(requestCache);
this.requestCache = requestCache;
}
}
Aí na classe de configuração, vc pede para usar seu handler.
anyRequest().authenticated().and().formLogin().loginPage("/login")
.successHandler(new CustomSuccessLoginHandler())