2013-04-05 4 views
1

내 api_controller.rb에 게시 할 때마다 내 레일 애플 리케이션에서 CSRF 경고 (내 세션 재설정)가 표시됩니다.서브 컨트롤러에 대한 CSRF 토큰 authencity

내 응용 프로그램은 Windows Phone 8의 phonegap에서 iframe에서 실행되고 내 application_controller에서는이 문제를 해결하기위한 p3p 헤더가 있습니다. 그러나이 경우 작동하지 않는 것 같습니다. 그것의 p3p는 거기 있지 않습니다 ...? 누구든지이 문제가 발생 했습니까?

class ApplicationController < ActionController::Base 

protect_from_forgery 
before_filter :header_fix 

protected 
    def header_fix 
    headers['P3P'] = 'CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV"' 
    end 
end 




class Api::ApiController < ApplicationController 
before_filter :login_required 

skip_before_filter :detect_device 
skip_before_filter :detect_browser 
skip_before_filter :record_log 

skip_before_filter :assign_packages 
skip_before_filter :assign_daily_bonus 

end 


[2646 - 2013/04/05 13:04:23] (INFO) Started POST "/api/chests" for 60.50.19.249 at 2013-04-05 13:04:23 +0800 
[2646 - 2013/04/05 13:04:23] (INFO) Processing by Api::ChestsController#create as */* 
[2646 - 2013/04/05 13:04:23] (INFO) Parameters: {"force_new"=>"true"} 
[2646 - 2013/04/05 13:04:23] (WARN) WARNING: Can't verify CSRF token authenticity 
[2646 - 2013/04/05 13:04:23] (INFO) User agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) 
[2646 - 2013/04/05 13:04:23] (DEBUG) User Load (4.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IS NULL LIMIT 1 
[2646 - 2013/04/05 13:04:23] (DEBUG) KeyPackage Load (1.2ms) SELECT `packages`.* FROM `packages` WHERE `packages`.`type` IN ('KeyPackage') ORDER BY cost 
[2646 - 2013/04/05 13:04:23] (DEBUG) CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IS NULL LIMIT 1 
[2646 - 2013/04/05 13:04:23] (DEBUG) CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IS NULL LIMIT 1 
[2646 - 2013/04/05 13:04:23] (WARN) Lost session [60.50.19.249] (/api/chests) - Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) 
+0

은 요청 전에 로그인 한 사용자입니까? – scones

+0

예. 사용자가 로그인하면 레일스 콘솔에 –

+0

게시하기 전에 모든 이벤트에 대한 사용자 ID가 표시됩니다 (브라우저에서 iframe없이 iframe의 내용에 직접 액세스 할 때)? – scones

답변

1

이 보석은 Ruby on Rails (https://github.com/grosser/ie_iframe_cookies)에서 작동합니다. 문제를 해결합니다.

내 p3p 헤더가 유효하고 내 사용자가 로그인 할 수 있지만 IE10이 이유는 모르겠습니다.