开发者

Locally 401 Working, Staging Server getting a 302 instead

I'm probably not going to get all the required info needed to help the first stab but I'll do the best I can and edit this as we go along.

I've got a Grails 1.3.7 application using Spring-Security-Core plugin. I'm working on code that deals with session timeouts and ajax requests. In the LoginController, I have the following:

def authAjax = {
    session.SPRING_SECURITY_SAVED_REQUEST_KEY = null
    response.sendError HttpServletResponse.SC_UNAUTHORIZED
}

In a global JavaScript file, I have the following:

$.ajaxSetup({
     error: function(xh开发者_开发问答r, status, err) {
       if (xhr.status == 401) {
         $('#login-dialog').dialog({ // show ajax login });
       }
     }
});

When I run this locally everything works as expected. When my session timesout, I see a 401 in FireBug console and I get the Login dialog. When I deploy this to our staging server, I'm only getting the 302 and never getting into authAjax therefor never getting the 401.

The main difference between local dev and staging is that I'm using mod_proxy with apache httpd to proxy the requests back and forth to Tomcat. My assumption is this is why I'm getting a 302 and not the 401 but I'm not 100% sure.

My question(s)

  1. Is the mod_proxy causing the 302
  2. How can I resolve this so that it works like it does locally, but still using mod_proxy.

UPDATE:

Per the recent comments, locally, when I get the 401 I am seeing this:

POST https://localhost:8080/admin/bookProject/edit 302 Moved Temporarily
GET http://localhost:8080/login/authAjax 401 Unauthorized

And I am seeing debug from the authAjax method

On the staging server I am getting:

POST https://server.com/admin/bookProject/edit 302 Moved Temporarily

And I am not seeing any debug from authAjax, so I'm not even getting there.


Code for your Ajax call:

statusCode: {
    401: function(){
        // redirect code to login page
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜