在政府医疗机构工作的乐趣之一是必须处理所有围绕PHI(受保护的健康信息)的偏执。不要误解我的意思,我支持尽一切可能保护人们的个人信息(健康状况、财务状况、上网习惯等),但有时人们会有点太神经质了。

举个例子:我们的一位州客户最近发现浏览器提供了保存密码的方便功能。我们都知道它已经存在了一段时间,完全是可选的,由最终用户决定是否使用它是一个明智的决定。然而,目前有一点骚动,我们被要求找到一种方法来禁用我们网站的功能。

问:网站有没有办法告诉浏览器不要提供记住密码的功能?我从事网络开发已经很长时间了,但我不知道我以前遇到过这种情况。

任何帮助都是感激的。


当前回答

我测试了很多解决方案。动态密码字段名,多个密码字段(假密码不可见),更改输入类型从“text”到“password”,autocomplete=“off”,autocomplete=“new-password”,…但是最近的浏览器没有解决这个问题。

为了摆脱密码记忆,我最后把密码当作输入字段,并“模糊”输入的文本。

它不如本地密码字段“安全”,因为选择键入的文本会显示为明文,但密码不会被记住。它还依赖于激活Javascript。

你将不得不估计使用下面的建议和密码记住选项导航的风险。

虽然密码记忆可以由用户管理(每个站点取消),但它适用于个人计算机,不适用于“公共”或共享计算机。

我的案例是一个在共享计算机上运行的ERP,所以我将在下面尝试我的解决方案。

<input style="background-color: rgb(239, 179, 196); color: black; text-shadow: none;" name="password" size="10" maxlength="30" onfocus="this.value='';this.style.color='black'; this.style.textShadow='none';" onkeypress="this.style.color='transparent'; this.style.textShadow='1px 1px 6px green';" autocomplete="off" type="text">

其他回答

我一直在做的是autocomplete="off"和使用javascript / jQuery清除密码字段的组合。

jQuery示例:

$(function() { 
    $('#PasswordEdit').attr("autocomplete", "off");
    setTimeout('$("#PasswordEdit").val("");', 50); 
});

通过使用setTimeout(),您可以等待浏览器在清除字段之前完成该字段,否则浏览器将总是在您清除字段后自动完成。

If you do not want to trust the autocomplete flag, you can make sure that the user types in the box using the onchange event. The code below is a simple HTML form. The hidden form element password_edited starts out set to 0. When the value of password is changed, the JavaScript at the top (pw_edited function) changes the value to 1. When the button is pressed, it checks the valueenter code here before submitting the form. That way, even if the browser ignores you and autocompletes the field, the user cannot pass the login page without typing in the password field. Also, make sure to blank the password field when focus is set. Otherwise, you can add a character at the end, then go back and remove it to trick the system. I recommend adding the autocomplete="off" to password in addition, but this example shows how the backup code works.

<html>
  <head>
    <script>
      function pw_edited() {
        document.this_form.password_edited.value = 1;
      }
      function pw_blank() {
        document.this_form.password.value = "";
      }
      function submitf() {
        if(document.this_form.password_edited.value < 1) {
          alert("Please Enter Your Password!");
        }
        else {
         document.this_form.submit();
        }
      }
    </script>
  </head>
  <body>
    <form name="this_form" method="post" action="../../cgi-bin/yourscript.cgi?login">
      <div style="padding-left:25px;">
        <p>
          <label>User:</label>
          <input name="user_name" type="text" class="input" value="" size="30" maxlength="60">
        </p>
        <p>
          <label>Password:</label>
          <input name="password" type="password" class="input" size="20" value="" maxlength="50" onfocus="pw_blank();" onchange="pw_edited();">
        </p>
        <p>
          <span id="error_msg"></span>
        </p>
        <p>
          <input type="hidden" name="password_edited" value="0">
          <input name="submitform" type="button" class="button" value="Login" onclick="return submitf();">
        </p>
      </div>
    </form>
  </body>
</html>

就像人们意识到的那样——“自动完成”属性在大多数时候都是有效的,但高级用户可以使用bookmarklet绕过它。

使用浏览器保存密码实际上可以增加对键盘记录的保护,所以最安全的选择可能是将密码保存在浏览器中,但使用主密码保护它们(至少在Firefox中是这样)。

面对同样的HIPAA问题,我找到了一个相对简单的解决方案,

创建一个隐藏密码字段,字段名为数组。 <input type="password" name="password[]" style="display:none" /> 实际密码字段使用相同的数组。 /> . <input type="password" name="password[]

浏览器(Chrome)可能会提示你“保存密码”,但无论用户是否选择保存,下次登录时,密码将自动填充隐藏的密码字段,数组中的零槽,使第一个槽为空。

我尝试定义数组,例如“password[part2]”,但它仍然记得。我认为如果它是一个无索引数组,它就会丢弃它因为它别无选择,只能把它放在第一个位置。

然后使用你选择的编程语言访问数组,比如PHP,

echo $_POST['password'][1];

另一种解决方案是使用隐藏表单使POST,其中所有输入的类型都是隐藏的。可见表单将使用“password”类型的输入。后一种表单永远不会被提交,所以浏览器根本无法拦截登录操作。