ziming / laravel-zxcvbn
Laravel 的 Zxcvbn 密码验证规则
2.2
2024-08-09 08:38 UTC
Requires
- php: ^8.1
- bjeavons/zxcvbn-php: ^1.3
- illuminate/contracts: ^10.0 | ^11.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- nunomaduro/collision: ^6.0 | ^7.0 | ^8.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0 | ^9.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5|^10.0
- spatie/laravel-ray: ^1.26
README
Laravel Zxcvbn 密码验证规则。没有更多,没有更少。
关于 Zxcvbn 的介绍,请参阅以下链接
https://dropbox.tech/security/zxcvbn-realistic-password-strength-estimation
安装
您可以通过 composer 安装此包
composer require ziming/laravel-zxcvbn
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="zxcvbn-config"
这是已发布配置文件的内容。默认最低分数设置为 3。
<?php return [ // If you wish to override the default min score in the config, // you can do so by passing in a second argument to the ZxcvbnRule constructor. // e.g. new ZxcvbnRule([], 4) 'min_score' => env('ZXCVBN_MIN_SCORE', 3), ];
bjeavons/zxcvbn-php 提供了关于 zxcvbn 分数的良好概述。
Scores are integers from 0 to 4:
- 0 means the password is extremely guessable (within 10^3 guesses), dictionary words like 'password' or 'mother' score a 0
- 1 is still very guessable (guesses < 10^6), an extra character on a dictionary word can score a 1
- 2 is somewhat guessable (guesses < 10^8), provides some protection from unthrottled online attacks
- 3 is safely unguessable (guesses < 10^10), offers moderate protection from offline slow-hash scenario
- 4 is very unguessable (guesses >= 10^10) and provides strong protection from offline slow-hash scenario
用法
// In your validation rules use Illuminate\Validation\Rules\Password; use Ziming\LaravelZxcvbn\Rules\ZxcvbnRule; [ 'name' => ['required'] 'email' => ['required', 'email'], 'password' => [ 'required', 'confirmed', 'min:8', new ZxcvbnRule([ request('email'), request('name'), ]), ], ]
## Testing
```bash
composer test
变更日志
有关最近更改的更多信息,请参阅 变更日志
贡献
有关详细信息,请参阅 贡献指南
安全漏洞
有关如何报告安全漏洞的详细信息,请参阅 我们的安全策略
鸣谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件