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

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

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

任何帮助都是感激的。


当前回答

我不确定它是否能在所有浏览器中工作,但你应该尝试在表单上设置autocomplete="off"。

<form id="loginForm" action="login.cgi" method="post" autocomplete="off">

禁用表单和密码存储提示并防止表单数据在会话历史中缓存的最简单和最简单的方法是使用值为“off”的自动完成表单元素属性。

从https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

一些小研究表明,这可以在IE中工作,但我不能保证;)

@Joseph:如果严格要求通过实际标记的XHTML验证(不知道为什么会这样),理论上你可以在之后用javascript添加这个属性,但禁用js的用户(可能可以忽略不计,如果你的网站需要js,则为零)仍然会保存他们的密码。

jQuery示例:

$('#loginForm').attr('autocomplete', 'off');

其他回答

恕我直言, 最好的方法是随机选择type=password的输入字段的名称。 使用“pwd”前缀,然后是一个随机数。 动态创建字段并将表单呈现给用户。

您的登录表单看起来像…

<form>
   <input type=password id=pwd67584 ...>
   <input type=text id=username ...>
   <input type=submit>
</form>

然后,在服务器端,当您分析客户端发布的表单时,捕获以“pwd”开头的字段,并将其用作“password”。

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

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

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

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

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

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

我不确定它是否能在所有浏览器中工作,但你应该尝试在表单上设置autocomplete="off"。

<form id="loginForm" action="login.cgi" method="post" autocomplete="off">

禁用表单和密码存储提示并防止表单数据在会话历史中缓存的最简单和最简单的方法是使用值为“off”的自动完成表单元素属性。

从https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

一些小研究表明,这可以在IE中工作,但我不能保证;)

@Joseph:如果严格要求通过实际标记的XHTML验证(不知道为什么会这样),理论上你可以在之后用javascript添加这个属性,但禁用js的用户(可能可以忽略不计,如果你的网站需要js,则为零)仍然会保存他们的密码。

jQuery示例:

$('#loginForm').attr('autocomplete', 'off');

我测试了很多解决方案。动态密码字段名,多个密码字段(假密码不可见),更改输入类型从“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">

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浏览器功能应该通过测试各种各样的条件和边缘情况来进行。