Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD README.md and docblock #8

Merged
merged 6 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

229 changes: 166 additions & 63 deletions .idea/workspace.xml

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# hash-verifier

hash verification using a nonce & verifying the hmac from the URL for a laravel application

## Installation

```bash
composer require dpc/hash-verifier
```

## Usage

TODO: Write usage instructions
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you attempt this based on the example I have given? If not I will add it later


## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## History

TODO: Write history
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

history isn't needed


## Credits

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

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
7 changes: 5 additions & 2 deletions src/AuthValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Dpc\HashVerifier;


use Illuminate\Database\Eloquent\Model;

/**
* Class AuthValidator
* @package Dpc\HashVerifier
*/
class AuthValidator implements AuthValidatorContract
{
protected $generator;
Expand Down Expand Up @@ -60,4 +63,4 @@ public function validate(array $params) : bool
return $this->validator->verify($params);
}

}
}
7 changes: 5 additions & 2 deletions src/AuthValidatorContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Dpc\HashVerifier;


use Illuminate\Database\Eloquent\Model;

/**
* Interface AuthValidatorContract
* @package Dpc\HashVerifier
*/
interface AuthValidatorContract
{

Expand Down Expand Up @@ -35,4 +38,4 @@ public function matches(Model $content, string $nonce) : bool;
* @return bool
*/
public function validate(array $params) : bool;
}
}
4 changes: 4 additions & 0 deletions src/AuthValidatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use Illuminate\Support\ServiceProvider;

/**
* Class AuthValidatorServiceProvider
* @package Dpc\HashVerifier
*/
class AuthValidatorServiceProvider extends ServiceProvider
{
/**
Expand Down
7 changes: 5 additions & 2 deletions src/Exceptions/HashFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Dpc\HashVerifier\Exceptions;


/**
* Class HashFailedException
* @package Dpc\HashVerifier\Exceptions
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't needed. It is understood from the namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok ill remove it

*/
class HashFailedException extends \Exception
{

Expand All @@ -13,4 +16,4 @@ public function __construct()
{
parent::__construct('Hash Validation Failed');
}
}
}
7 changes: 5 additions & 2 deletions src/Exceptions/NonceFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Dpc\HashVerifier\Exceptions;


/**
* Class NonceFailedException
* @package Dpc\HashVerifier\Exceptions
*/
class NonceFailedException extends \Exception
{

Expand All @@ -13,4 +16,4 @@ public function __construct()
{
parent::__construct('Authentication failed because nonce does not match');
}
}
}
7 changes: 5 additions & 2 deletions src/HMacValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Dpc\HashVerifier;


/**
* Class HMacValidator
* @package Dpc\HashVerifier
*/
class HMacValidator implements HMacValidatorContract
{

Expand Down Expand Up @@ -60,4 +63,4 @@ protected function validate(array $params, $hmac) : bool
return hash_equals($hmac, $hash);

}
}
}
7 changes: 5 additions & 2 deletions src/HMacValidatorContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Dpc\HashVerifier;


/**
* Interface HMacValidatorContract
* @package Dpc\HashVerifier
*/
interface HMacValidatorContract
{
/**
Expand All @@ -13,4 +16,4 @@ interface HMacValidatorContract
* @return bool
*/
public function verify(array $params) : bool;
}
}
7 changes: 5 additions & 2 deletions src/NonceContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Dpc\HashVerifier;


use Illuminate\Database\Eloquent\Model;

/**
* Interface NonceContract
* @package Dpc\HashVerifier
*/
interface NonceContract
{
/**
Expand Down Expand Up @@ -35,4 +38,4 @@ public function store(Model $content, string $nonce) : void;
* @return bool
*/
public function matches(Model $content, string $nonce) : bool;
}
}
6 changes: 5 additions & 1 deletion src/NonceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use Illuminate\Database\Eloquent\Model;
use function Sodium\randombytes_buf;

/**
* Class NonceGenerator
* @package Dpc\HashVerifier
*/
class NonceGenerator implements NonceContract
{
/**
Expand Down Expand Up @@ -55,4 +59,4 @@ public function matches(Model $content, string $nonce) : bool

return $nonce && $stored === $nonce;
}
}
}