luppakorva/laravel-password-exposed-validation-rule

Laravel validation rule that checks if a password has been exposed in a data breach

v2.6.0 2021-04-02 19:22 UTC

README

This package provides a Laravel validation rule that checks if a password has been exposed in a data breach. It uses the haveibeenpwned.com passwords API via the divineomega/password_exposed library.

laravel-password-exposed.png

Travis CI Coverage Status StyleCI 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646976696e656f6d6567612f6c61726176656c2d70617373776f72642d6578706f7365642d76616c69646174696f6e2d72756c652e737667

Installation

To install, just run the following Composer command.

composer require divineomega/laravel-password-exposed-validation-rule

Please note that this package requires Laravel 5.1 or above.

Usage

The following code snippet shows an example of how to use the password exposed validation rule.

use DivineOmega\LaravelPasswordExposedValidationRule\PasswordExposed;

$request->validate([
    'password' => ['required', new PasswordExposed()],
]);

If you wish, you can also set a custom validation message, as shown below.

use DivineOmega\LaravelPasswordExposedValidationRule\PasswordExposed;

$request->validate([
    'password' => ['required', (new PasswordExposed())->setMessage('This password is not secure.')],
]);