Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit d9a0f3d

Browse files
README: Add Package Banner
1 parent 8cbd121 commit d9a0f3d

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

Diff for: README.md

+31-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1+
![Pwned Passwords](https://banners.beyondco.de/Laravel%20Pwned%20Passwords.png?theme=light&packageName=ubient%2Flaravel-pwned-passwords&pattern=brickWall&style=style_1&description=Automatically+check+password+safety+against+existing+data+breaches&md=1&fontSize=100px&images=lock-closed&widths=auto&heights=250)
2+
3+
<p align="center">
4+
<a href="https://github.com/ubient/laravel-pwned-passwords/releases">
5+
<img src="https://img.shields.io/github/release/ubient/laravel-pwned-passwords.svg?style=flat-square" alt="Latest Version">
6+
</a>
7+
<a href="https://travis-ci.org/ubient/laravel-pwned-passwords">
8+
<img src="https://img.shields.io/travis/ubient/laravel-pwned-passwords/master.svg?style=flat-square" alt="Build Status">
9+
</a>
10+
<a href="https://scrutinizer-ci.com/g/ubient/laravel-pwned-passwords">
11+
<img src="https://img.shields.io/scrutinizer/g/ubient/laravel-pwned-passwords.svg?style=flat-square" alt="Quality Score">
12+
</a>
13+
<a href="https://styleci.io/repos/151966705"><img src="https://styleci.io/repos/151966705/shield" alt="StyleCI"></a>
14+
<a href="https://packagist.org/packages/ubient/laravel-pwned-passwords">
15+
<img src="https://img.shields.io/packagist/dt/ubient/laravel-pwned-passwords.svg?style=flat-square" alt="Total Downloads">
16+
</a>
17+
</p>
18+
119
# Pwned Passwords
220

3-
[![Latest Version](https://img.shields.io/github/release/ubient/laravel-pwned-passwords.svg?style=flat-square)](https://github.com/ubient/laravel-pwned-passwords/releases)
4-
[![Build Status](https://img.shields.io/travis/ubient/laravel-pwned-passwords/master.svg?style=flat-square)](https://travis-ci.org/ubient/laravel-pwned-passwords)
5-
[![Quality Score](https://img.shields.io/scrutinizer/g/ubient/laravel-pwned-passwords.svg?style=flat-square)](https://scrutinizer-ci.com/g/ubient/laravel-pwned-passwords)
6-
[![StyleCI](https://styleci.io/repos/151966705/shield)](https://styleci.io/repos/151966705)
7-
[![Total Downloads](https://img.shields.io/packagist/dt/ubient/laravel-pwned-passwords.svg?style=flat-square)](https://packagist.org/packages/ubient/laravel-pwned-passwords)
21+
This package provides a validation rule that allows you to prevent or limit the re-use of passwords that are known to be unsafe for ongoing usage.
22+
The result is a more secure application, as your users will have a much lower risk of having their accounts taken over.
823

9-
This package provides a Laravel validation rule that can be used to check a password
10-
against TroyHunt's [Pwned Passwords (haveibeenpwned.com)](https://haveibeenpwned.com/Passwords),
11-
a database containing 517,238,891 real world passwords previously exposed in data breaches.
24+
### How it works
1225

13-
By using this validation rule, you can prevent re-use of passwords that are unsuitable for ongoing usage,
14-
resulting in a more secure application, as your users will have a much lower risk of having their accounts taken over.
26+
Internally, the validation rule uses what is known as a [k-Anonymity model](https://en.wikipedia.org/wiki/K-anonymity) that allows for the password to be looked up without giving up the user's privacy or security:
1527

16-
##### How it works
28+
- First, we hash the password using SHA-1
29+
- Next, it looks up the first 5 characters of this hash against TroyHunt's [Pwned Passwords (haveibeenpwned.com)](https://haveibeenpwned.com/Passwords) API.
30+
- The API then responds with a list _suffixes_ to these first 5 characters that we are looking up.
31+
- Finally, we search through the list, checking whether the suffix of our hashed password matches any of the entries.
1732

18-
In order to protect the value of the source password being searched for, Pwned Passwords implements a [k-Anonymity model](https://en.wikipedia.org/wiki/K-anonymity) that allows a password to be searched for by partial hash.
19-
This works by hashing the source password with SHA-1, and only sending the first 5 characters of that hash to the API.
20-
By checking whether the rest of the SHA-1 hash occurs within the output, we can verify both whether the password was pwned previously, and how frequently.
33+
This will then tell us whether a password was breached, and if so, how frequent.
2134

2235
## Installation
2336

@@ -48,16 +61,16 @@ protected function validator(array $data)
4861
}
4962
```
5063

51-
You can also relax the rule, allowing passwords that have been pwned multiple times.
52-
In the example below, passwords that have been pwned between 0 and 4 times are allowed:
64+
It is also possible to relax the rule, allowing passwords that have been breached multiple times.
65+
In the following example, passwords that have been pwned between 0 and 4 times are allowed:
5366

5467
```php
5568
$request->validate([
5669
'password' => 'required|string|min:6|confirmed|pwned:5',
5770
]);
5871
```
5972

60-
Of course, you can also use a Rule object instead:
73+
Alternatively, you can also achieve the same using a Rule object:
6174

6275
```php
6376
use Ubient\PwnedPasswords\Rules\Pwned;
@@ -68,8 +81,7 @@ $request->validate([
6881
```
6982

7083
#### Handling Lookup Errors
71-
When the Pwned Passwords API cannot be queried, the default behavior is to accept the password as non-pwned and to send a warning message to the log.
72-
While this doesn't add much value, it does allow you to be aware of when a pwned password was allowed, and to potentially manually act on this.
84+
When the [Pwned Passwords](https://haveibeenpwned.com/Passwords) API cannot be queried, the default behavior is to accept the password as non-pwned and to send a warning message to the log. While this by itself doesn't add much value, it does allow you to be aware of when a pwned password was allowed, and to potentially manually act on this.
7385

7486
If you would like to automatically do something else based on this lookup error (such as marking the request as potentially pwned), or want to decline the password instead,
7587
you may create your own implementation of the [LookupErrorHandler](src/Contracts/LookupErrorHandler.php) and overwrite the default binding in your application:

0 commit comments

Comments
 (0)