如何更改' csrf-param'的元标记名称?和' csrf-token'在Rails 4?

时间:2014-09-26 20:10:55

标签: ruby-on-rails ruby-on-rails-4 csrf

正如标题所述,我想知道如何更改csrf-paramcsrf-token的元标记名称?

<meta content="authenticity_token" name="csrf-param" />
<meta content="123456" name="csrf-token" />

我问这个,因为出于安全原因我想隐藏,我正在使用哪种技术来支持我的网站。 Chrome插件Wappalyzer使用此元标记作为Ruby on Rails的指标。

enter image description here

1 个答案:

答案 0 :(得分:1)

创建名为change_csrf_name.rb

的初始值设定项

在此文件中,您可以更改 :name => 'xyz' 。请注意,它可能会破坏您不期望的一些内置功能。<​​/ p>

module ActionView
  module Helpers
    module CsrfHelper
      def csrf_meta_tags
        if protect_against_forgery?
          [
            tag('meta', :name => 'csrf-param', :content => request_forgery_protection_token),
            tag('meta', :name => 'csrf-token', :content => form_authenticity_token)
          ].join("\n").html_safe
        end
      end
    end
  end
end
相关问题