正如标题所述,我想知道如何更改csrf-param
和csrf-token
的元标签名称?
<meta content="authenticity_token" name="csrf-param" />
<meta content="123456" name="csrf-token" />
我之所以问这个问题,是因为出于安全考虑,我想隐藏我网站使用的技术。Chrome插件Wappalyzer使用这些meta标签作为Ruby on Rails的指示器。
正如标题所述,我想知道如何更改csrf-param
和csrf-token
的元标签名称?
<meta content="authenticity_token" name="csrf-param" />
<meta content="123456" name="csrf-token" />
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
jquery_ujs
可能是另一个问题。Rails 在ActionView::Helpers::CsrfHelper
中定义它 (https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/csrf_helper.rb)。 - Dan Fairaizl