swop / github-webhook-security-checker
v3.1
2020-11-14 10:26 UTC
Requires
- php: ^7.2|^8.0
- ext-json: *
- psr/http-message: ^1.0
Requires (Dev)
- laminas/laminas-diactoros: ^2.4
- phpunit/phpunit: ^8.0
This package is not auto-updated.
Last update: 2022-02-01 13:03:03 UTC
README
此库提供了一系列工具,在处理GitHub webhook请求时可能会很有用。
安装
推荐通过 Composer 安装此库。
composer require "swop/github-webhook"
用法
有效载荷签名检查
SignatureValidator
将验证传入的GitHub webhook请求是否正确签名。
use Swop\GitHubWebHook\Security\SignatureValidator; $validator = new SignatureValidator(); /** @var \Psr\Http\Message\ServerRequestInterface $request */ if ($validator->validate($request, 'secret')) { // Request is correctly signed }
创建GitHub事件对象
GitHubEventFactory
可以构建表示GitHub事件的GitHubEvent对象。
use Swop\GitHubWebHook\Event\GitHubEventFactory; $factory = new GitHubEventFactory(); /** @var \Psr\Http\Message\ServerRequestInterface $request */ $gitHubEvent = $factory->buildFromRequest(RequestInterface $request); $gitHubEvent->getType(); // Event type $gitHubEvent->getPayload(); // Event deserialized payload
贡献
请参阅 CONTRIBUTING 文件。
原始贡献者
- Sylvain MAUDUIT (@Swop) 作为主要作者。
许可证
此库在MIT许可证下发布。请参阅捆绑的完整 LICENSE 文件。