rails形成帮助密码安全问题

时间:2013-11-08 08:08:40

标签: ruby-on-rails ruby

这是字体代码。

<%= form_for(:something, :html=> {:id => 'login'}, :url => 'login/create') do |form| %>
        <h1>Log In</h1>
        <fieldset id="inputs">
            <%= form.text_field :username, :placeholder => 'Username', :autofocus=>true%>

            <%= password_field_tag(:password, :placeholder => 'Password') %>
            <%= password_field_tag :userpass1, placeholder: 'Password'%>
            <%= password_field_tag :userpass, params[:userpass], placeholder: 'Password', class: 'input-small'%>

        </fieldset>
        <fieldset id="actions">
            <input type="submit" id="submit" value="Log in">
            <a href="/registration/register">Register</a>
        </fieldset>

        <%end%>

如果我提交,它会像这样发送,

Processing by LoginController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"2RQKkdOZf2HL+dsY2peWYUIaY78WBZBvNveKKBvZv60=", "something"=>{"username
"=>"test"}, "password"=>"[FILTERED]", "userpass1"=>"test2", "userpass"=>"est3"}

在这里,第一个密码字段是通过过滤发送的,但其他两个只是显示用户键入的内容。

问题是什么?

并且最大的问题是,在我发送并检查请求标题后,

它显示了所有参数,甚至是像这样被记录的数据,

enter image description here

对此有什么好的解决方案吗?!

1 个答案:

答案 0 :(得分:0)

你可能有行

config.filter_parameters += [:password]
在config / application.rb中

。将其修改为:

config.filter_parameters += [:password, :userpass, :userpass1, :userpass2]

这会导致在日志中过滤其他参数。

第二个“问题”根本不是问题。如果要在请求中过滤它们,您如何让服务器知道您的参数是什么?