我有两个应用程序需要通过 HTTP 相互通信。一个是 PHP 应用程序,另一个是我的主要应用程序 Rails 应用程序。我需要 PHP 应用程序通过向其发送数据来与 Rails 应用程序通信,但是当我这样做时,我收到无效的真实性 token 错误。有没有办法解决?或者我将如何创建自己的 token 来传递 POST,以便我的 Rails 应用程序进行身份验证?
最佳答案
来自documentation for ActionController::RequestForgeryProtection::ClassMethods
您可以通过指定和 :except 或强制跳过之前的过滤器来跳过身份验证 token 要求....来自文档的示例...
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
关于php - Rails 3 protect_from_forgery 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3685316/