{"id":21819374,"url":"https://github.com/dflydev/dflydev-stack-hawk","last_synced_at":"2025-06-20T16:36:51.491Z","repository":{"id":9608523,"uuid":"11532110","full_name":"dflydev/dflydev-stack-hawk","owner":"dflydev","description":"Hawk Stack middleware","archived":false,"fork":false,"pushed_at":"2013-08-02T04:22:14.000Z","size":252,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T02:28:58.577Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dflydev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-19T16:28:16.000Z","updated_at":"2017-06-03T20:28:13.000Z","dependencies_parsed_at":"2022-09-11T13:22:55.684Z","dependency_job_id":null,"html_url":"https://github.com/dflydev/dflydev-stack-hawk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-hawk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-hawk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-hawk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-hawk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dflydev","download_url":"https://codeload.github.com/dflydev/dflydev-stack-hawk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248810788,"owners_count":21165181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-27T16:18:43.031Z","updated_at":"2025-04-14T02:29:02.399Z","avatar_url":"https://github.com/dflydev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Hawk Stack Middleware\n=====================\n\nA [Stack][0] middleware to enable [Hawk][1] authentication following the\n[STACK-2 Authentication][2] conventions.\n\n\nInstallation\n------------\n\nThrough [Composer][3] as [dflydev/stack-hawk][4].\n\n\nUsage\n-----\n\nThe Hawk middleware accepts the following options:\n\n * **credentials_provider**: *(required)* Either an instance of\n   `Dflydev\\Hawk\\Credentials\\CredentialsProviderInterface` or a callable that\n   receives an ID as its only argument and is expected to return a\n   `Dflydev\\Hawk\\Credentials\\CredentialsInterface` or null.\n * **sign_response**: Should responses be signed? Boolean. Default **true**.\n * **validate_payload_response**: Should payload responses be validated?\n   Boolean. Default **true**.\n * **validate_payload_request**: Should payload requests be validated? Boolean.\n   Default **true**.\n * **crypto**: An instance of `Dflydev\\Hawk\\Crypto\\Crypto` or a callable that\n   will return an instance of `Dflydev\\Hawk\\Crypto\\Crypto`.\n * **server**: An instance of `Dflydev\\Hawk\\Server\\ServerInterface` or a\n   callable that will return an instance of\n   `Dflydev\\Hawk\\Server\\ServerInterface`.\n * **time_provider**: An instance of `Dflydev\\Hawk\\Time\\TimeProviderInterface`\n   or a callable that will return an instance of\n   `Dflydev\\Hawk\\Time\\TimeProviderInterface`.\n * **token_translator**: A callable that receives a\n   `Dflydev\\Hawk\\Credentials\\CredentialsInterface` as its only argument and is\n   expected to return a token. Default implementation returns\n   `$credentials-\u003eid()` as the token.\n * **firewall**: A firewall configuration compatible with\n   [dflydev/stack-firewall][5].\n\n```php\n\u003c?php\n\nuse Dflydev\\Hawk\\Credentials\\Credentials;\n\n$credentialsProvider = function ($id) {\n    // Simulate a know valid set of credentials.\n    $validCredentials = new Credentials('key1234', 'sha256', 'id1234');\n\n    if ($validCredentials === $id) {\n        return $validCredentials;\n    }\n};\n\n$tokenTranslator = function (CredentialsInterface $credentials) {\n    // This is the same as the default implementation and shown merely for\n    // demonstration purposes. If the token should be something other than\n    // the ID this callback can be defined; otherwise, if the ID is sufficient,\n    // defining this callback can be skipped entirely.\n    return $credentials-\u003eid();\n};\n\n$app = new Dflydev\\Stack\\Hawk($app, [\n    'firewall' =\u003e [\n        ['path' =\u003e '/api'], // Only /api requests will be protected by Hawk!\n    ],\n    'credentials_provider' =\u003e $credentialsProvider,\n    'token_translator' =\u003e $tokenTranslator,\n    'sign_response' =\u003e false, // do not sign the response; default true\n]);\n```\n\n\nLicense\n-------\n\nMIT, see LICENSE.\n\n\nCommunity\n---------\n\nIf you have questions or want to help out, join us in the **#stackphp** or **#dflydev** channels on **irc.freenode.net**.\n\n\n[0]: http://stackphp.com/\n[1]: https://github.com/hueniverse/hawk\n[2]: http://stackphp.com/specs/STACK-2/\n[3]: http://getcomposer.org\n[4]: https://packagist.org/packages/dflydev/stack-hawk\n[5]: https://packagist.org/packages/dflydev/stack-firewall\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflydev%2Fdflydev-stack-hawk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdflydev%2Fdflydev-stack-hawk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflydev%2Fdflydev-stack-hawk/lists"}