zenepay / password-policy
Configurable password history and expiry policies for Laravel applications.
Requires
- php: >=8.3
- illuminate/console: ^10.0|^11.0|^12.0|^13.0
- illuminate/contracts: ^10.0|^11.0|^12.0|^13.0
- illuminate/database: ^10.0|^11.0|^12.0|^13.0
- illuminate/notifications: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- symfony/mailer: ^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
README
Configurable password history and expiry policies for Laravel applications.
Installation
composer require zenepay/password-policy php artisan vendor:publish --tag=password-policy-config php artisan vendor:publish --tag=password-policy-migrations php artisan migrate
User model
Add the trait to the authenticatable model:
use Zenepay\PasswordPolicy\Traits\PasswordExpirable; class User extends Authenticatable { use PasswordExpirable; }
The package records the initial password and subsequent password changes. Password reuse checks the most recent number of hashes configured by previous_passwords_limit.
Validation
use Zenepay\PasswordPolicy\Rules\NoPreviousPassword; 'password' => [ 'required', 'confirmed', NoPreviousPassword::ofUser($request->user()), ],
Middleware
Register the middleware in the host application and configure middleware_redirect_route to a route that displays the password renewal form:
'check-password-expired' => Zenepay\PasswordPolicy\Middleware\CheckPasswordExpired::class,
Expiry notifications
Run the command manually or schedule it in the host application:
php artisan password-policy:check-expiry
The command is intentionally not scheduled automatically. Configure the password broker and reset route in config/password-policy.php before enabling it.
Configuration
The package publishes config/password-policy.php. Important defaults include 90 expiry days and a five-password history limit.
License
MIT