ruby - Session Problem with Rails 3 -
i'm using authlogic 2.1.6 authorization in rails 3.0.5 , have session cookie problem ajax requests.
after post or put ajax call i'm getting 401 response , new session key. after every call return 401 response. before post or put call every call succeeds.
this doesn't happen in test mode, in development , production mode.
does know how avoid that?
edit: think there problem forgery protection authenticity key, because after disabling forgery protection worked fine.
this request header produce 401:
accept:*/* cache-control:max-age=0 content-type:application/json; charset=utf-8 origin:http://localhost:3000 referer:http://localhost:3000/ user-agent:mozilla/5.0 (macintosh; u; intel mac os x 10_6_6; de-de) applewebkit/533.19.4 (khtml, gecko) version/5.0.3 safari/533.19.4 x-requested-with:xmlhttprequest
rails log entry following:
started post "/users.json" 127.0.0.1 @ tue apr 12 10:47:33 +0200 2011 processing userscontroller#create json parameters: {"user"=>{"password_confirmation"=>"[filtered]", "group_id"=>2, "lastname"=>"test1", "prename"=>"test1", "password"=>"[filtered]", "login"=>"test1"}} rendered text template (0.0ms) completed 401 unauthorized in 19ms (views: 0.9ms | activerecord: 3.0ms)
edit2:
next weird thing: i send basic auth header instead of cookie session id, i'm not getting 401, weird
a basic error 'forgery protection authenticity' forget adding csrf_meta_tag
in layout add in header tag. without no ajax request token.
if it's not ajax use simple_form helper generate token in form
Comments
Post a Comment