[ruby on rails] rails2の、authenticity_token出力をとめる

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

トラックバック(0)

このブログ記事を参照しているブログ一覧: rails2の、authenticity_token出力をとめる

このブログ記事に対するトラックバックURL: http://www.pistolfly.jp/mt/mt-tb-alt.cgi/378

コメントする