Simply put, this blog is a dumping ground for things I find interesting or worth remembering relating to Java, programming, web, lean, agile, etc, etc.
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.
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.
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.
ReplyDeletevery useful ,thx so much~
ReplyDelete
ReplyDeletevery useful thank you