Thursday, May 30, 2013

Spring Security: Log In via AJAX

Here are some classes to handle the logging in via an ajax request.  By following these same principles and these examples you can also create a class to handle logging out via ajax too.


  1. For people wanting to get a redirect back to the restricted page the user was trying to access, you will have to instead implement SavedRequestAwareAuthenticationSuccessHandler. You can then write 'request.getSession().getAttribute("SPRING_SECURITY_SAVED_REQUEST")' to get lots of data you need. The attribute name may change with the version of spring security you have.