afiqiqmal/lara-pass-policy

Laravel Password History
1,795 1
Install
composer require afiqiqmal/lara-pass-policy
Latest Version:1.3.1
PHP:^7.4 || ^8.0
Laravel:7 – 11
License:MIT
Last Updated:Jan 18, 2026
Links: GitHub  ·  Packagist
Maintainer: afiqiqmal

Laravel Password Policy

Latest Version on Packagist Total Downloads Donate

Installation

You can install the package via composer:

composer require afiqiqmal/lara-pass-policy

You can publish and run the migrations with:

php artisan vendor:publish --provider="Afiqiqmal\LaraPassPolicy\LaraPassPolicyServiceProvider" --tag="migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="Afiqiqmal\LaraPassPolicy\LaraPassPolicyServiceProvider" --tag="config"

Out of the box, this package provide a view (Blade and Vue templates) to allow users to change own password. If you want to customize the default page you can publish the views with:

php artisan vendor:publish --provider="Afiqiqmal\LaraPassPolicy\LaraPassPolicyServiceProvider" --tag="views"

and customize as you like in:

  • resources/views/auth/verify-password-change.blade.php, for standard stack (Blade templates)
  • resource/js/Pages/Auth/VerifyPasswordChange.vue, if your stack integrate Inertia

Then, be sure to specify the view name in config/lara-pass-policy.views.password-changed.

NOTE: Currently, only Vue stack are supported out of the box: for React/Svelte stack you must create a new page component in resources/js/Pages/Auth, just like the Vue page provided.

Usage

Add HasPasswordPolicy trait to the authenticable model
Add MustVerifyPasswordPolicy interface to the authenticable model
class User extends Authenticable implements MustVerifyPasswordPolicy
{
     use HasPasswordPolicy;
     ...
     ...
}
Add Middleware

Add EnsurePasswordIsChanged middleware in $routeMiddleware

protected $routeMiddleware = [
    ...
    'password_changed' => EnsurePasswordIsChanged::class,
    ...
];

so you can attach it to your routes:

// routes/web.php

Route::middleware(['auth', 'password_changed'])->group(function () {
    return view('welcome');
});

Translations.

You may translate the package string messages (defined in config lara-pass.messages) adding the translated strings in lang/<locale>.json files.

Environment settings.

If you want to disable Password Policy on specific environment (ex: local) set to false this variable in .env file:

# Set to false to disable password policy.
PASSWORD_POLICY_ENABLED=false

You may also customize the number of days before the passwords expire setting the variable in .env file:

# Set to false to disable password policy.
PASSWORD_LIFETIME=30

Validation rules.

If you need to apply your own default password rules, you should define a defaults callback within the boot method of one of your application's service providers, as described in Laravel docs: this package will validate new passwords against those defaults.


Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
1.3.1 ^7.4 || ^8.0 ^7 || ^8 || ^9 || ^10 || ^11 MIT
1.3.0 ^7.4 || ^8.0 ^7 || ^8 || ^9 || ^10 || ^11 MIT
1.2.2 ^7.4|^8.0 ^7 || ^8 || ^9 || ^10 MIT
1.2.1 ^7.4|^8.0 ^7 || ^8 || ^9 || ^10 MIT
1.2.0 ^7.4|^8.0 ^7 || ^8 || ^9 MIT