winter / wn-pwnedpasswords-plugin
为密码添加了 notpwned 验证规则,以检查密码是否与 HIBP Pwned Passwords 服务冲突
Requires
- ext-curl: *
- composer/installers: ~1.11
This package is auto-updated.
Last update: 2024-08-24 03:17:05 UTC
README
添加了 notpwned:min
验证规则,用于通过范围搜索(k-匿名性)功能检查值是否与 HaveIBeenPwned Pwned Passwords 服务冲突,以保护隐私和安全。如果某个值被泄露超过 :min
(默认为1)次,则提供的值将验证失败。
安装
要从 市场 安装,点击“添加到项目”按钮,然后在更新项目之前选择要添加的项目。
要从后端安装,转到 设置 -> 更新和插件 -> 安装插件,然后搜索 Winter.PwnedPasswords
。
要从 仓库 安装,将其克隆到 plugins/winter/pwnedpasswords,然后从项目的根目录运行 composer update
以获取依赖项。
使用 Composer 安装,在项目根目录中运行 composer require winter/wn-pwnedpasswords-plugin
。
文档
通过密码泄露次数进行限制
您可以限制被拒绝的密码为那些至少泄露了一定次数的密码。例如,password
已泄露 3,303,003 次,然而 P@ssword!
只泄露了 118 次。如果我们想阻止 password
但不阻止 P@ssword!
,我们可以将最小数量指定为 150,如下所示
'password' => 'required|string|min:6|notpwned:150|confirmed',
在后台认证中强制执行此规则
要在后台认证系统中强制执行此规则,在 config/winter/pwnedpasswords/config.php
文件中创建一个文件,并将以下内容放入其中
<?php return [ /* |-------------------------------------------------------------------------- | Enforce "notpwned" rule on backend users |-------------------------------------------------------------------------- | | When this is enabled, the 'notpwned' validation rule is enforced on all | backend users by default. This means that they will not be able to update | their password to any password detected in a password breach, and if a | backend user tries to login with a "pwned" password, they will be rejected | and a password reset email will be sent to their email address for them to | change their password. */ 'enforceOnBackendUsers' => true, ];
覆盖验证消息
要覆盖验证消息,将插件的 lang/en/lang.php
文件复制到 project/lang/$locale/winter/pwnedpasswords/lang.php
。