We are using Spring Security plugin version 1.2.7.3 with Grails 2.2.1.
In my Config.groovy
, I do:
grails.plugins.springsecurity.auth.ajaxLoginFormUrl = "/mylogin/authAjax"
thinking that, when there is an Ajax request, Spring Security will invoke authAjax()
in MyloginController
if the User's HttpSession has timed out.
As per doc, I ensure that the header X-Requested-With
with value XMLHttpRequest
is in the Ajax request so the plugin knows it is an Ajax request.
My expectation is authAjax()
will be invoked and I can make that return a 401, so the UI knows it needs to pop up another login screen.
However, instead of the authAjax()
getting invoked, a 302 is returned to the UI with the location field set to http://localhost:8080/MyApplication/mycontroller/authAjax
This means I'll have to put in something very hackey on my UI, check for a 302 and check the location field and then make the User re-login. I would much prefer to have a 401 returned.
Any ideas what I am doing wrong?
Thanks a million.