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

Rob*_*bin 6 ruby-on-rails csrf ruby-on-rails-4

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

<meta content="authenticity_token" name="csrf-param" />
<meta content="123456" name="csrf-token" />
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述

Bla*_*son 1

创建一个名为的初始化程序change_csrf_name.rb

在此文件中,您可以更改:name => 'xyz'. 请注意,它可能会破坏一些您意想不到的内置功能。

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
Run Code Online (Sandbox Code Playgroud)