Results 1 to 2 of 2

Thread: Spring Security - Ajax login/logout?

  1. #1
    Join Date
    Jun 2009
    Posts
    20

    Default Spring Security - Ajax login/logout?

    I've got a login form configured to work with Spring Security - action set to j_spring_security_check and fields called j_username and j_password etc. The form works fine as normal, but I'd like to Ajaxify the form so that clicking log in will just update parts of the page. I figure there are two main possibilities: I could point the form at a controller and manually call the Spring Security stuff before returning an appropriate AJAX view; or I may be able to intercept the login process and specify the AJAX view to return, based on some request parameter maybe.

    I'm not sure what code I would need for the first one, and I simply don't know if the second one is possible or how (without being overly hackish and breaking things). Can anyone give me any advice on this?

  2. #2

    Default

    Quote Originally Posted by NickB View Post
    I've got a login form configured to work with Spring Security - action set to j_spring_security_check and fields called j_username and j_password etc. The form works fine as normal, but I'd like to Ajaxify the form so that clicking log in will just update parts of the page. I figure there are two main possibilities: I could point the form at a controller and manually call the Spring Security stuff before returning an appropriate AJAX view; or I may be able to intercept the login process and specify the AJAX view to return, based on some request parameter maybe.

    I'm not sure what code I would need for the first one, and I simply don't know if the second one is possible or how (without being overly hackish and breaking things). Can anyone give me any advice on this?
    IMHO, the action you need to take should be on client side only. In other words, you will need to develop a client side javascript which will make call to j_spring_security_check url via XmlHttpRequest object and will interpret returned response. Spring Security on the server side will process authentication request and will respond either by redirecting or forwarding to you another url for both success and error cases. As a result, your client side javascript should understand how to handle and know what to extract from those responses and then will update DOM.

    Good luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •