【发布时间】:2018-07-04 05:15:17
【问题描述】:
根据 Rails 文档
config.filter_parameters 用于过滤掉参数 您不希望在日志中显示,例如密码或信用卡 数字。默认情况下,Rails 通过添加
Rails.application.config.filter_parameters += [:password]在config/initializers/filter_parameter_logging.rb。参数过滤器 通过部分匹配正则表达式工作。
那么,为什么当我提交下面的表单时
<%= form_with model: @user, url: admin_user_path, method: :delete do %>
<%= label_tag :password, t('forms.password') %>
<%= text_field_tag :password, nil %>
<%= button_tag t('forms.save'), type: 'submit' %>
<% end %>
我可以在日志中看到我的密码吗?
<ActionController::Parameters {"utf8"=>"✓", "_method"=>"delete", "authenticity_token"=>"r22P2Mi1xcWOjRHGogoFaDcOec9/FgkC9btCo66qmqaKG/zwzUkbUGtATsTKV19OOYK80VBf1h0CzFtoRltQOA==", "password"=>"x", "button"=>"", "controller"=>"admin/users", "action"=>"destroy", "id"=>"at-example-com"} permitted: false>
密码不应该是[过滤]吗?
【问题讨论】:
-
@meagar 谢谢你的链接 ;)
标签: ruby-on-rails ruby