https://github.com/intracto/passwordvalidator
Symfony validation for Intracto's standard password policy
https://github.com/intracto/passwordvalidator
Last synced: about 1 year ago
JSON representation
Symfony validation for Intracto's standard password policy
- Host: GitHub
- URL: https://github.com/intracto/passwordvalidator
- Owner: Intracto
- Created: 2019-10-04T09:17:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-27T08:50:11.000Z (over 2 years ago)
- Last Synced: 2025-04-13T15:42:14.225Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PasswordValidator
Symfony validation for Intracto's standard password policy
### The policy consists of:
- minimum length (defaults on 8 characters)
- at least one upper cased character
- at least one lower cased character
- at least one number
- cannot equal the username
- maximum length (defaults on integer limit) - de facto optional
## installation
Using composer:
```
composer require intracto/password-validator
```
The password constraint and -validator are dependent on both `symfony/validator` and `symfony/security-core`.
## Usage
The validator is designed as a class validator on an entity implementing the `Symfony\Component\Security\Core\User\UserInterface`.
In order to validate the password, you need to provide the accessor and property path to the plain password which needs validation.
A basic working example would be:
```
/**
* @Password(plainPasswordAccessor="getPlainPassword", plainPasswordProperty="plain_password")
*/
class User implements UserInterface
{
/** @var string */
private $plain_password;
/** @return string */
public function getPlainPassword(): string
{
return $this->plain_password;
}
...
}
```
## Contributions
Do you feel the code or policy are too rigid, or just not strict enough? Feel free to open up an issue and/or submit a pull request with your suggestions.