Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit e4c1b55

Browse files
committed
fixup: move and edit docs
1 parent 3095cd3 commit e4c1b55

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

Diff for: doc/book/validators/undisclosed-password.md renamed to docs/book/validators/undisclosed-password.md

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Undisclosed Password Validator
22

3+
- **Since 2.13.0**
4+
35
`Zend\Validator\UndisclosedPassword` allows you to validate if a given password was found in data breaches using the service [Have I Been Pwned?](https://www.haveibeenpwned.com), in a secure, anonymous way using [K-Anonymity](https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2) to ensure passwords are not send in full over the wire.
46

57
> ### Installation requirements
68
>
7-
> This validator needs to make a request over HTTP, therefor it requires an HTTP client of your choice that implements [PSR-18](https://www.php-fig.org/psr/psr-18/) and [PSR-17](https://www.php-fig.org/psr/psr-17/) request and response factories.
9+
> This validator needs to make a request over HTTP; therefore it requires an HTTP client. The validator provides support only for HTTP clients implementing [PSR-18](https://www.php-fig.org/psr/psr-18/) and [PSR-17](https://www.php-fig.org/psr/psr-17/) request and response factories.
810
>
9-
> Make sure you have it installed before using this validator:
11+
> To ensure you have these installed before using this validator, run the following:
1012
>
1113
> ```bash
1214
> $ composer require psr/http-client
@@ -15,30 +17,33 @@
1517
1618
## Basic usage
1719
18-
To validate if a password was disclosed in a known data breach, you need to provide a HTTP Client that implements `Psr\Http\Client\ClientInterface`, a `Psr\Http\Message\RequestFactoryInterface` and a `Psr\Http\Message\ResponseFactoryInterface` to the constructor and validate the password you want to check.
20+
The validator has three required constructor arguments:
21+
22+
- an HTTP Client that implements `Psr\Http\Client\ClientInterface`
23+
- a `Psr\Http\Message\RequestFactoryInterface` instance
24+
- a `Psr\Http\Message\ResponseFactoryInterface` instance
1925
20-
If the password was found via the service, `isValid` will return `false`. If the password was not found, `isValid` will return `true`.
26+
Once you have an instance, you can then pass a password to its `isValid()` method to determine if it has been disclosed in a known data breach.
27+
28+
If the password was found via the service, `isValid()` will return `false`. If the password was not found, `isValid()` will return `true`.
2129
2230
```php
2331
$validator = new Zend\Validator\UndisclosedPassword(
2432
$httpClient, // a PSR-18 HttpClientInterface
2533
$requestFactory, // a PSR-17 RequestFactoryInterface
2634
$responseFactory // a PSR-17 ResponseFactoryInterface
2735
);
28-
```
29-
```php
30-
$result = $validator->isValid('password');
36+
37+
$result = $validator->isValid('password');
3138
// $result is FALSE because "password" was found in a data breach
32-
```
3339
34-
```php
3540
$result = $validator->isValid('8aDk=XiW2E.77tLfuAcB');
3641
// $result is TRUE because "8aDk=XiW2E.77tLfuAcB" was not found in a data breach
3742
```
3843
3944
## A simple command line example
4045
41-
In this example I'm using `zendframework/zend-diactoros` for HTTP messaging and `php-http/curl-client` as the HTTP client. Let's begin with installation of all required packages:
46+
In this example, I'm using `zendframework/zend-diactoros` to provide HTTP messages, and `php-http/curl-client` as the HTTP client. Let's begin with installation of all required packages:
4247
4348
```bash
4449
$ composer require \
@@ -47,10 +52,10 @@ $ composer require \
4752
php-http/discovery \
4853
php-http/curl-client \
4954
zendframework/zend-diactoros \
50-
zendframework/zend-validator
55+
zendframework/zend-validator
5156
```
5257
53-
Next thing is I create a file `undisclosed.php` where I will put in my code.
58+
Next, I create a file, `undisclosed.php`, where I put my code:
5459
5560
```php
5661
<?php
@@ -74,13 +79,13 @@ echo 'Password "password" is ' . ($undisclosedPassword->isValid('password') ? 'n
7479
echo 'Password "NVt3MpvQ" is ' . ($undisclosedPassword->isValid('NVt3MpvQ') ? 'not disclosed' : 'disclosed') . PHP_EOL;
7580
```
7681
77-
To run it, I use PHP on the command line:
82+
To run it, I use the PHP command line interpreter:
7883
7984
```bash
8085
$ php undisclosed.php
8186
```
8287
83-
And it will give me the following output:
88+
And it gives me the following output:
8489
8590
```bash
8691
Password "password" is disclosed

Diff for: mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ nav:
3535
- Step: validators/step.md
3636
- StringLength: validators/string-length.md
3737
- Timezone: validators/timezone.md
38+
- UndisclosedPassword: validators/undisclosed-password.md
3839
- Uri: validators/uri.md
3940
- Uuid: validators/uuid.md
4041
- "File Validators":

0 commit comments

Comments
 (0)