dilneiss/laravel-nist-password-rules
Composer 安装命令:
composer require dilneiss/laravel-nist-password-rules
包简介
🔒 Provides Laravel validation rules that follow the password related recommendations found in NIST Special Publication 800-63B.
README 文档
README
This package provides Laravel validation rules that follow the password related recommendations found in NIST Special Publication 800-63B section 5.
Laravel NIST Password Rules implements the following recommendations.
| Recommendation | Implementation |
|---|---|
| [...] at least 8 characters in length | A standard validation rule in all rule sets to validate against this minimum length of 8 characters. |
| Passwords obtained from previous breach corpuses | The BreachedPasswords rule securely checks the password against previous 3rd party data breaches, using the Have I Been Pwned - Pwned Passwords API. |
| Dictionary words | The DictionaryWords rule checks the password against a list of over 102k dictionary words. |
| Context-specific words, such as the name of the service, the username | The ContextSpecificWords rule checks the password does not contain the provided username, and any words defined the configured app name or app URL. |
| Context-specific words, [...] and derivatives thereof | The DerivativesOfContextSpecificWords rule checks the password is not too similar to the provided username, and any words defined the configured app name or app URL. |
| Repetitive or sequential characters (e.g. ‘aaaaaa’, ‘1234abcd’) | The RepetitiveCharacters and SequentialCharacters rules checks if the password consists of only repetitive or sequential characters. |
It also provides methods to return validation rules arrays for various scenarios, such as register, login, and password changes. These arrays can be passed directly into the Laravel validator.
Installation
Laravel NIST Password Rules can be easily installed using Composer. Just run the following command from the root of your project.
composer require langleyfoxall/laravel-nist-password-rules
If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started.
Optionally, you may publish the package's translation files with the following Artisan command.
php artisan vendor:publish --provider="LangleyFoxall\LaravelNISTPasswordRules\ServiceProvider"
Usage
To use the Laravel NIST Password Rules in your project, first use the
PasswordRules class, then call the appropriate static methods to return
an array of appropriate validation rules. There are methods available for
the following scenerios.
- Register
- Change password, with old password
- Change password, without old password
- Optionally change password, with old password
- Optionally change password, without old password
- Login
See the code below for example usage syntax.
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules; // Register $this->validate($request, [ 'email' => 'required', 'password' => PasswordRules::register($request->email), ]); // Register, without requiring password confirmation $this->validate($request, [ 'email' => 'required', 'password' => PasswordRules::register($request->email, false), ]); // Change password, with old password $this->validate($request, [ 'old_password' => 'required', 'password' => PasswordRules::changePassword($request->email, 'old_password'), ]); // Change password, without old password $this->validate($request, [ 'password' => PasswordRules::changePassword($request->email), ]); // Optionally change password, with old password $this->validate($request, [ 'old_password' => 'required', 'password' => PasswordRules::optionallyChangePassword($request->email, 'old_password'), ]); // Optionally change password, without old password $this->validate($request, [ 'password' => PasswordRules::optionallyChangePassword($request->email), ]); // Login $this->validate($request, [ 'email' => 'required', 'password' => PasswordRules::login(), ]);
The optionallyChangePassword method supplies validation rules that are
appropriate for forms in which the password can be optionally changed if
filled in.
dilneiss/laravel-nist-password-rules 适用场景与选型建议
dilneiss/laravel-nist-password-rules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.21k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 12 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dilneiss/laravel-nist-password-rules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dilneiss/laravel-nist-password-rules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2023-12-19