Skip to content

Commit 73ca5bc

Browse files
author
Abdalrhman Emad Saad
committed
Add PassAudit package.
0 parents  commit 73ca5bc

31 files changed

Lines changed: 10435 additions & 0 deletions

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/vendor/
2+
node_modules/
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Laravel 4 specific
7+
bootstrap/compiled.php
8+
app/storage/
9+
10+
# Laravel 5 & Lumen specific
11+
public/storage
12+
public/hot
13+
14+
# Laravel 5 & Lumen specific with changed public path
15+
public_html/storage
16+
public_html/hot
17+
18+
storage/*.key
19+
.env
20+
Homestead.yaml
21+
Homestead.json
22+
/.vagrant
23+
.phpunit.result.cache

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Abdalrhman Emad Saad
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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.

composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "kettasoft/pass-audit",
3+
"description": "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.",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"Kettasoft\\PassAudit\\": "src/"
9+
}
10+
},
11+
"autoload-dev": {
12+
"psr-4": {
13+
"Kettasoft\\PassAudit\\Tests\\": "tests/",
14+
"Kettasoft\\PassAudit\\Tests\\Database\\Factories\\": "tests/database/factories/"
15+
}
16+
},
17+
"authors": [
18+
{
19+
"name": "Abdalrhman Emad Saad",
20+
"email": "kettasoft@gmail.com"
21+
}
22+
],
23+
"minimum-stability": "dev",
24+
"require-dev": {
25+
"laravel/framework": "^10",
26+
"pestphp/pest": "2.x-dev",
27+
"orchestra/testbench": "^8.0",
28+
"mockery/mockery": "1.6.x-dev"
29+
},
30+
"scripts": {
31+
"test": [
32+
"vendor/bin/pest --configuration=phpunit.xml"
33+
]
34+
},
35+
"config": {
36+
"allow-plugins": {
37+
"pestphp/pest-plugin": true
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)