Package Data | |
---|---|
Maintainer Username: | DivineOmega |
Maintainer Contact: | jordan@langleyfoxall.co.uk (Jordan Hall) |
Package Create Date: | 2018-10-26 |
Package Last Update: | 2024-07-03 |
Home Page: | |
Language: | PHP |
License: | LGPL-3.0-only |
Last Refreshed: | 2024-11-11 15:19:29 |
Package Statistics | |
---|---|
Total Downloads: | 507,431 |
Monthly Downloads: | 5,285 |
Daily Downloads: | 98 |
Total Stars: | 208 |
Total Watchers: | 9 |
Total Forks: | 49 |
Total Open Issues: | 10 |
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. |
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.
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.
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.
See the code below for example usage syntax.
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;
// Register
$this->validate($request, [
'email' => 'required',
'password' => PasswordRules::register($request->email),
]);
// Change password, with old password
$this->validate($request, [
'old_password' => 'required',
'password' => PasswordRules::changePassword($request->email, $request->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, $request->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.