Rails 3 protect_from_forgery问题

时间:2010-09-10 14:17:38

标签: php ruby-on-rails protect-from-forgery

我有两个需要通过HTTP相互通信的应用程序。一个是PHP应用程序,另一个是我的主应用程序,Rails应用程序。我需要PHP应用程序通过向其发送数据来与Rails应用程序通信,但是当我这样做时,我收到了无效的真实性令牌错误。有没有办法解决?或者我如何创建自己的令牌以传递POST以便我的Rails应用程序进行身份验证?

1 个答案:

答案 0 :(得分:15)

来自documentation for ActionController::RequestForgeryProtection::ClassMethods

您可以通过指定和:跳过身份验证令牌要求,或者强制跳过前过滤器....文档示例...

class FooController < ApplicationController
    protect_from_forgery :except => :index

    # you can disable csrf protection on controller-by-controller basis:
    skip_before_filter :verify_authenticity_token
end