https://github.com/dflydev/dflydev-stack-hawk
Hawk Stack middleware
https://github.com/dflydev/dflydev-stack-hawk
Last synced: 12 months ago
JSON representation
Hawk Stack middleware
- Host: GitHub
- URL: https://github.com/dflydev/dflydev-stack-hawk
- Owner: dflydev
- License: mit
- Created: 2013-07-19T16:28:16.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-08-02T04:22:14.000Z (almost 13 years ago)
- Last Synced: 2025-04-14T02:28:58.577Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 246 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Hawk Stack Middleware
=====================
A [Stack][0] middleware to enable [Hawk][1] authentication following the
[STACK-2 Authentication][2] conventions.
Installation
------------
Through [Composer][3] as [dflydev/stack-hawk][4].
Usage
-----
The Hawk middleware accepts the following options:
* **credentials_provider**: *(required)* Either an instance of
`Dflydev\Hawk\Credentials\CredentialsProviderInterface` or a callable that
receives an ID as its only argument and is expected to return a
`Dflydev\Hawk\Credentials\CredentialsInterface` or null.
* **sign_response**: Should responses be signed? Boolean. Default **true**.
* **validate_payload_response**: Should payload responses be validated?
Boolean. Default **true**.
* **validate_payload_request**: Should payload requests be validated? Boolean.
Default **true**.
* **crypto**: An instance of `Dflydev\Hawk\Crypto\Crypto` or a callable that
will return an instance of `Dflydev\Hawk\Crypto\Crypto`.
* **server**: An instance of `Dflydev\Hawk\Server\ServerInterface` or a
callable that will return an instance of
`Dflydev\Hawk\Server\ServerInterface`.
* **time_provider**: An instance of `Dflydev\Hawk\Time\TimeProviderInterface`
or a callable that will return an instance of
`Dflydev\Hawk\Time\TimeProviderInterface`.
* **token_translator**: A callable that receives a
`Dflydev\Hawk\Credentials\CredentialsInterface` as its only argument and is
expected to return a token. Default implementation returns
`$credentials->id()` as the token.
* **firewall**: A firewall configuration compatible with
[dflydev/stack-firewall][5].
```php
id();
};
$app = new Dflydev\Stack\Hawk($app, [
'firewall' => [
['path' => '/api'], // Only /api requests will be protected by Hawk!
],
'credentials_provider' => $credentialsProvider,
'token_translator' => $tokenTranslator,
'sign_response' => false, // do not sign the response; default true
]);
```
License
-------
MIT, see LICENSE.
Community
---------
If you have questions or want to help out, join us in the **#stackphp** or **#dflydev** channels on **irc.freenode.net**.
[0]: http://stackphp.com/
[1]: https://github.com/hueniverse/hawk
[2]: http://stackphp.com/specs/STACK-2/
[3]: http://getcomposer.org
[4]: https://packagist.org/packages/dflydev/stack-hawk
[5]: https://packagist.org/packages/dflydev/stack-firewall