Download the PHP package code-pros/password-policy without Composer
On this page you can find all versions of the php package code-pros/password-policy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download code-pros/password-policy
More information about code-pros/password-policy
Files in code-pros/password-policy
Download code-pros/password-policy
More information about code-pros/password-policy
Files in code-pros/password-policy
Vendor code-pros
Package password-policy
Short Description Create a password policy and validate strings against it
License MIT
Package password-policy
Short Description Create a password policy and validate strings against it
License MIT
Please rate this library. Is it a good library?
Informations about the package password-policy
README
Create a Password Policy and validate passwords against it.
Useful for when a user is creating/updating their password.
Installation
Use Composer to manage your dependencies:
composer require code-pros/password-policy
Example
/**
* Setup a password policy
* This policy is from OWASP's security cheat sheet. Look it up for good reading!
*
* Must match 3/4 of the following
* - Lowercase character
* - Uppercase character
* - Special character
* - Digit
* Must match all of the following
* - between 10 and 128 characters
* - no consecutive characters more than twice
*/
$childPolicy = \CodePros\PasswordPolicy\Builder::create()
->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Lowercase(1))
->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Uppercase(1))
->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Digit(1))
->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Special(1))
->pctRulesMustPass(75)
->build();
$policy = \CodePros\PasswordPolicy\Builder::create()
->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Length(10, 128))
->addMustNotRule(new \CodePros\PasswordPolicy\Rules\ConsecutiveCharacters(3))
->mustPassPolicy($childPolicy)
->build();
/**
* Validate a password
*/
$valid = $policy->validate('user supplied password');
/**
* Get back a list of rules and whether the last validation passed each.
*/
$messages = $policy->getDetailedStatus();
Development
Development Process
- Make your changes.
- Test with PHPUnit.
Build Process
- Choose a new version number according to semver.
- Summarize your changes in CHANGELOG with the new version number.
- Create a git tag with the version number.
- Push the changes and tag.
All versions of password-policy with dependencies
PHP Build Version
Package Version
Requires
php Version
^7.1 || ^8.0
The package code-pros/password-policy contains the following files
Loading the files please wait ....