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

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

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

任何帮助都是感激的。


当前回答

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

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

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

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

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

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

其他回答

我知道的一种方法是在提交表单之前使用(例如)JavaScript从密码字段中复制值。

这样做的主要问题是解决方案与JavaScript绑定在一起。

同样,如果它可以绑定到JavaScript,那么在向服务器发送请求之前,不妨在客户端对密码进行哈希处理。

网站有没有办法告诉浏览器不要提供记住密码的功能?

该网站通过使用<input type="password">告诉浏览器这是一个密码。所以如果你必须从网站的角度来做这件事,那么你就必须改变它。(显然我不建议这样做)。

最好的解决方案是让用户配置浏览器,这样它就不会记住密码。

我被给了一个类似的任务禁用自动填写登录名和密码的浏览器,经过大量的试验和错误,我发现下面的解决方案是最优的。只需在原始控件之前添加以下控件。

<input type="text" style="display:none">
<input type="text" name="OriginalLoginTextBox">

<input type="password" style="display:none">
<input type="text" name="OriginalPasswordTextBox">

这在IE11和Chrome 44.0.2403.107上运行正常

Since most of the autocomplete suggestions, including the accepted answer, don't work in today's web browsers (i.e. web browser password managers ignore autocomplete), a more novel solution is to swap between password and text types and make the background color match the text color when the field is a plain text field, which continues to hide the password while being a real password field when the user (or a program like KeePass) is entering a password. Browsers don't ask to save passwords that are stored in plain text fields.

The advantage of this approach is that it allows for progressive enhancement and therefore doesn't require Javascript for a field to function as a normal password field (you could also start with a plain text field instead and apply the same approach but that's not really HIPAA PHI/PII-compliant). Nor does this approach depend on hidden forms/fields which might not necessarily be sent to the server (because they are hidden) and some of those tricks also don't work either in several modern browsers.

jQuery插件:

https://github.com/cubiclesoft/php-flexforms-modules/blob/master/password-manager/jquery.stoppasswordmanager.js

相关源代码来自上述链接:

(function($) {
$.fn.StopPasswordManager = function() {
    return this.each(function() {
        var $this = $(this);

        $this.addClass('no-print');
        $this.attr('data-background-color', $this.css('background-color'));
        $this.css('background-color', $this.css('color'));
        $this.attr('type', 'text');
        $this.attr('autocomplete', 'off');

        $this.focus(function() {
            $this.attr('type', 'password');
            $this.css('background-color', $this.attr('data-background-color'));
        });

        $this.blur(function() {
            $this.css('background-color', $this.css('color'));
            $this.attr('type', 'text');
            $this[0].selectionStart = $this[0].selectionEnd;
        });

        $this.on('keydown', function(e) {
            if (e.keyCode == 13)
            {
                $this.css('background-color', $this.css('color'));
                $this.attr('type', 'text');
                $this[0].selectionStart = $this[0].selectionEnd;
            }
        });
    });
}
}(jQuery));

演示:

https://barebonescms.com/demos/admin_pack/admin.php

点击菜单中的“添加条目”,然后滚动到页面底部的“模块:停止密码管理器”。

免责声明:虽然这种方法适用于视力正常的人,但屏幕阅读器软件可能存在问题。例如,屏幕阅读器可能会大声读出用户的密码,因为它看到的是纯文本字段。使用上述插件还可能产生其他不可预见的后果。改变内置的web浏览器功能应该通过测试各种各样的条件和边缘情况来进行。

好吧,这是一个非常老的帖子,但我仍然会给出我的解决方案,这是我的团队长期以来一直在努力实现的。我们只是在表单中添加了一个新的input type="password"字段,并将其包装在div中,并使div隐藏起来。确保这个div在实际的密码输入之前。 这为我们工作,它没有提供任何保存密码选项

扑通- http://plnkr.co/edit/xmBR31NQMUgUhYHBiZSg?p=preview

HTML:

<form method="post" action="yoururl">
      <div class="hidden">
        <input type="password"/>
      </div>
      <input type="text" name="username" placeholder="username"/>
      <input type="password" name="password" placeholder="password"/>
    </form>

CSS:

.hidden {display:none;}