{"id":19655844,"url":"https://github.com/kaxiluo/api-signature","last_synced_at":"2026-04-16T01:31:51.712Z","repository":{"id":57004865,"uuid":"366769704","full_name":"kaxiluo/api-signature","owner":"kaxiluo","description":"api signature and verification. guzzle middleware,  signature verify middleware","archived":false,"fork":false,"pushed_at":"2021-05-29T16:10:08.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-22T01:03:15.618Z","etag":null,"topics":["php-middleware"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaxiluo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-12T15:50:07.000Z","updated_at":"2024-07-05T04:01:41.000Z","dependencies_parsed_at":"2022-08-21T13:50:53.220Z","dependency_job_id":null,"html_url":"https://github.com/kaxiluo/api-signature","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kaxiluo/api-signature","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaxiluo%2Fapi-signature","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaxiluo%2Fapi-signature/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaxiluo%2Fapi-signature/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaxiluo%2Fapi-signature/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaxiluo","download_url":"https://codeload.github.com/kaxiluo/api-signature/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaxiluo%2Fapi-signature/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31867710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["php-middleware"],"created_at":"2024-11-11T15:24:12.647Z","updated_at":"2026-04-16T01:31:51.664Z","avatar_url":"https://github.com/kaxiluo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API Signature, Verification\n\napi signature and verification, easy to use it by middleware. or use it alone.\n\n- Request signer\n- Use request sign middleware to create guzzle client\n- Signature validator\n- General signature verify middleware\n- Use signature verify middleware in laravel、hyperf ...\n\n## Installing\n\nPackage is available on [Packagist](https://packagist.org/packages/kaxiluo/api-signature),\n\n```bash\ncomposer require kaxiluo/api-signature\n```\n\n## Usage\n\n### Client (Request Sign)\n\n```php\n// use as guzzle client config\n$config = [\n    'base_uri' =\u003e 'https://yourserver.host',\n    'verify' =\u003e false,\n];\n// create guzzle client with request sign middleware\n$client = \\Kaxiluo\\ApiSignature\\Client\\GuzzleClientFactory::createClient('1', 'iamsecret', $config);\n// enjoy..\n$client-\u003eget('/test');\n```\n\nother, use it alone see:\n`\\Kaxiluo\\ApiSignature\\Client\\RequestSigner`\n\n### Server (Signature Verify)\n\nusing laravel middleware\n\n```php\nuse Kaxiluo\\ApiSignature\\Server\\SignatureVerifyLaravelMiddleware;\n\nclass MySignatureVerifyMiddleware extends SignatureVerifyLaravelMiddleware\n{\n    // custom signature header name. default is X-Signature\n    protected $headerName = 'X-Your-Custom-Name';\n    \n    // nonce ttl. default is 300 s\n    protected $lifetime = 500;\n\n    protected function getAppSecretByAppId($appId): string\n    {\n        // TODO: Implement getAppSecretByAppId() method.\n        // you can filter app_secret from config\n        //return config('api.your-client.app_secret');\n    }\n\n    protected function getCacheProvider()\n    {\n        return app('cache.store');\n    }\n}\n```\n\nusing hyperf middleware\n\n```php\nuse Kaxiluo\\ApiSignature\\Exception\\InvalidSignatureException;\nuse Kaxiluo\\ApiSignature\\Server\\SignatureVerifyPsrMiddleware;\nuse Psr\\Container\\ContainerInterface;\nuse Psr\\SimpleCache\\CacheInterface;\n\nclass MySignatureVerifyMiddleware extends SignatureVerifyPsrMiddleware\n{\n    /**\n     * @var ContainerInterface\n     */\n    protected $container;\n\n    public function __construct(ContainerInterface $container)\n    {\n        $this-\u003econtainer = $container;\n    }\n\n    protected function handleInvalidSignature(InvalidSignatureException $exception)\n    {\n        return $this-\u003econtainer-\u003eget(\\Hyperf\\HttpServer\\Contract\\ResponseInterface::class)\n            -\u003ejson(['error' =\u003e $exception-\u003egetMessage()])\n            -\u003ewithStatus(401);\n    }\n\n    protected function getCacheProvider(): CacheInterface\n    {\n        return $this-\u003econtainer-\u003eget(CacheInterface::class);\n    }\n\n    protected function getAppSecretByAppId($appId): string\n    {\n        // TODO: Implement getAppSecretByAppId() method.\n        // you can filter app_secret from config\n    }\n}\n```\n\nother, use it alone see:\n`\\Kaxiluo\\ApiSignature\\Server\\SignatureValidator`, `\\Kaxiluo\\ApiSignature\\Server\\SignatureVerifyMiddleware`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaxiluo%2Fapi-signature","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaxiluo%2Fapi-signature","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaxiluo%2Fapi-signature/lists"}