|
| 1 | +# PassAudit |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + <a href="https://github.com/kettasoft/PassAudit/releases"> |
| 5 | + <img src="https://img.shields.io/github/release/kettasoft/PassAudit.svg?style=flat-square" alt="Latest Version"> |
| 6 | + </a> |
| 7 | + <a href="https://travis-ci.org/kettasoft/PassAudit"> |
| 8 | + <img src="https://img.shields.io/travis/kettasoft/PassAudit/master.svg?style=flat-square" alt="Build Status"> |
| 9 | + </a> |
| 10 | + <a href="https://packagist.org/packages/kettasoft/PassAudit"> |
| 11 | + <img src="https://img.shields.io/packagist/dt/kettasoft/PassAudit.svg?style=flat-square" alt="Total Downloads"> |
| 12 | + </a> |
| 13 | +</p> |
| 14 | + |
| 15 | +PassAudit is a powerful and efficient Laravel package designed to enhance the security of user passwords in your application. This package provides a comprehensive solution to prevent users from reusing their previous passwords, thereby mitigating the risk of unauthorized access. |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +You can install the package via Composer: |
| 20 | + |
| 21 | +```bash |
| 22 | +composer require kettasoft/PassAudit |
| 23 | +``` |
| 24 | + |
| 25 | +## Configuration |
| 26 | + |
| 27 | +<!-- ### Steps to Configure --> |
| 28 | + |
| 29 | +1. **Register Service Provider** |
| 30 | + |
| 31 | +- Add the service provider to the config/app.php file in the providers array: |
| 32 | + |
| 33 | +```php |
| 34 | +'providers' => [ |
| 35 | + Kettasoft\PassAudit\PassAuditServiceProvider::class, |
| 36 | + ... |
| 37 | +], |
| 38 | +``` |
| 39 | + |
| 40 | +**Publish Configuration** |
| 41 | + |
| 42 | +- Publish the package configuration file: |
| 43 | + |
| 44 | +```dash |
| 45 | +php artisan vendor:publish --provider="Kettasoft\PassAudit\PassAuditServiceProvider" --tag="config" |
| 46 | +``` |
| 47 | + |
| 48 | +- This will create a passaudit.php file in your config directory where you can customize the settings. |
| 49 | + |
| 50 | +**Publish Migration** |
| 51 | + |
| 52 | +- Publish the migration file: |
| 53 | + |
| 54 | +```dash |
| 55 | +php artisan vendor:publish --provider="Kettasoft\PassAudit\PassAuditServiceProvider" --tag="migrations" |
| 56 | +``` |
| 57 | + |
| 58 | +Then, run the migration: |
| 59 | + |
| 60 | +```dash |
| 61 | +php artisan migrate |
| 62 | +``` |
| 63 | + |
| 64 | +## Usage |
| 65 | + |
| 66 | +**Use Trait in User Model** |
| 67 | + |
| 68 | +Add the `PassAudit` trait to your `User` model: |
| 69 | + |
| 70 | +```php |
| 71 | +namespace App\Models; |
| 72 | + |
| 73 | +use Illuminate\Foundation\Auth\User as Authenticatable; |
| 74 | +use Kettasoft\PassAudit\PassAudit; |
| 75 | + |
| 76 | +class User extends Authenticatable |
| 77 | +{ |
| 78 | + use PassAudit; |
| 79 | + |
| 80 | + //... |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +**Implement Interface to User Model** |
| 85 | + |
| 86 | +- Ensure your `User` model implements the `HasPassAuditChecker`: |
| 87 | + |
| 88 | +```php |
| 89 | +namespace App\Models; |
| 90 | + |
| 91 | +use Kettasoft\PassAudit\Contracts\HasPassAuditChecker; |
| 92 | + |
| 93 | +class User extends Authenticatable implements HasPassAuditChecker |
| 94 | +{ |
| 95 | + // |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +**Use Rule Validation in Request** |
| 100 | + |
| 101 | +- You can use the `PassAuditRule` in your request validation to prevent users from reusing their previous passwords: |
| 102 | + |
| 103 | +```php |
| 104 | +namespace App\Http\Requests; |
| 105 | + |
| 106 | +use Illuminate\Foundation\Http\FormRequest; |
| 107 | +use Kettasoft\PassAudit\Rules\PassAuditRule; |
| 108 | + |
| 109 | +class UpdatePasswordRequest extends FormRequest |
| 110 | +{ |
| 111 | + public function rules() |
| 112 | + { |
| 113 | + return [ |
| 114 | + 'password' => ['required', 'string', 'min:8', new PassAuditRule($this->user())], |
| 115 | + ]; |
| 116 | + } |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +### Customization |
| 121 | + |
| 122 | +You can customize the behavior of the package by modifying the `passaudit.php` configuration file. Options include: |
| 123 | + |
| 124 | +- The number of previous passwords to keep track of |
| 125 | +- The hashing algorithm to use |
| 126 | + |
| 127 | +### Contributing |
| 128 | + |
| 129 | +Thank you for considering contributing to PassAudit! Please read the contributing guide before making a pull request. |
| 130 | + |
| 131 | +### License |
| 132 | + |
| 133 | +PassAudit is open-sourced software licensed under the MIT license. |
0 commit comments