| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Stack middleware to enable Hawk authentication following the STACK-2 Authentication conventions.
Through Composer as dflydev/stack-hawk.
The Hawk middleware accepts the following options:
<?php
use Dflydev\Hawk\Credentials\Credentials;
$credentialsProvider = function ($id) {
// Simulate a know valid set of credentials.
$validCredentials = new Credentials('key1234', 'sha256', 'id1234');
if ($validCredentials === $id) {
return $validCredentials;
}
};
$tokenTranslator = function (CredentialsInterface $credentials) {
// This is the same as the default implementation and shown merely for
// demonstration purposes. If the token should be something other than
// the ID this callback can be defined; otherwise, if the ID is sufficient,
// defining this callback can be skipped entirely.
return $credentials->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
]);MIT, see LICENSE.
If you have questions or want to help out, join us in the #stackphp or #dflydev channels on irc.freenode.net.
| Back | FazBrowse Home | New Git URL |