A PHP library for validating password_hash passwords, rehashing when needed, and upgrading legacy password hashes.
Password Validator is a PHP library that validates passwords using PHP's `password_hash()` and `password_verify()` functions. It solves the problem of securely managing passwords by automatically rehashing them when needed and providing a smooth upgrade path from legacy hashing algorithms to modern, secure ones.
PHP developers building applications that require secure user authentication and need to maintain or migrate from legacy password hashing systems.
Developers choose Password Validator for its simplicity in implementing secure password practices, its seamless legacy hash upgrades, and its extensible decorator-based architecture that automates rehashing and persistence.
Validates passwords against PHP's password_hash function using PASSWORD_DEFAULT. Will rehash when needed, and will upgrade legacy passwords with the Upgrade decorator.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The UpgradeDecorator allows transparent migration from old hashes like SHA-512 to password_hash using a callback validator, making it easy to modernize without user disruption, as demonstrated in the usage examples.
Leverages password_needs_rehash() to automatically update hashes when algorithms or costs change, ensuring passwords adhere to current security standards without manual intervention.
Uses decorators like StorageDecorator for automatic persistence and UpgradeDecorator for legacy upgrades, providing flexibility to add custom validation or storage logic, as shown in the chaining examples.
Encourages VARCHAR(255) database fields to accommodate future algorithm updates, aligning with PHP's PASSWORD_DEFAULT and preventing schema issues down the line.
Implementing and chaining decorators requires additional setup and understanding of the pattern, which can be cumbersome for simple projects or developers unfamiliar with object-oriented design.
Without using StorageDecorator, developers must manually save rehashed passwords, as emphasized in multiple 'IMPORTANT' notes, creating a potential security gap if overlooked.
Focuses only on password hashing and validation, lacking built-in support for broader authentication needs like token handling, user registration, or password policy enforcement.