Skip to content

Commit

Permalink
validator & contract removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan-DPC committed Nov 3, 2017
1 parent c8a9f6d commit 78a6f62
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 107 deletions.
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,29 @@ This will create a `validator.php` in your config folder. The key indicates the
> Do not use your secret directly in config file. Instead fetch it from the `.env` or server environment variables.
## Usage
Inject the validator contract in your class:
Inject the nonce generator contract and/or HMAC validator contract in your class:
```php
public function __construct(AuthValidatorContract $validator)
public function __construct(NonceContract $generator)
{
$this->validator = $validator;
$this->generator = $generator;
}
```
To generate a nonce:
```php
$nonce = $this->validator->generateNonce($user)
$nonce = $this->generator->generateNonce($user)
```
The nonce will be automatically stored in the session with key as `nonce'. To retrieve it call:
```php
$nonce = $this->generator->getStoredNonce();
```

Ensure that you do not mutate the nonce.


To verify whether the nonce matches,
To verify whether the nonce matches

```php
$nonceMatches = $this->validator->matches($user, $nonce);
$nonceMatches = $this->generator->matches($user, $nonce);
```

To validate if the hmac matches the components of the URL:
Expand All @@ -57,10 +62,23 @@ This package follows [semver](http://semver.org/). Features introduced & any bre
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## Credits
## Author

[Dylan DPC](https://github.com/Dylan-DPC)

## Versioning

This package follows semver. Features introduced & any breaking changes created in major releases are mentioned in releases.

## Support

If you need help or have any questions you can:

* Create an issue here
* Send a tweet to @DPC_22
* Email me at dylan.dpc@gmail.com
* DM me on the [larachat](https://larachat.co) slack team (@Dylan DPC)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
2 changes: 0 additions & 2 deletions config/validator.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

return [
'key' => 'id',
'secret' => 'foo',

];
60 changes: 0 additions & 60 deletions src/AuthValidator.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/AuthValidatorContract.php

This file was deleted.

1 change: 0 additions & 1 deletion src/AuthValidatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function register() : void
{
$this->app->bind(NonceContract::class, NonceGenerator::class);
$this->app->bind(HMacValidatorContract::class, HMacValidator::class);
$this->app->bind(AuthValidatorContract::class, AuthValidator::class);
}

}

0 comments on commit 78a6f62

Please sign in to comment.