rails2の、authenticity_token出力をとめる
rails2から導入されたauthenticity_tokenによるCSRF対策を無効にする方法。
この検証に失敗した場合、以下の例外が発生する。ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken)特定のアクションでauthenticity_tokenの出力、検証を無効にする。
class TestController < ApplicationController
protect_from_forgery :except => [:hello]
def hello
self.allow_forgery_protection = false
end
end
コントローラのアクションすべてでauthenticity_tokenの出力、検証を無効にする。
class ApplicationController < ActionController::Base #protect_from_forgery # See ActionController::RequestForgeryProtection for details self.allow_forgery_protection = false end


コメントする