swop/github-webhook-security-checker

此包已被放弃,不再维护。作者建议使用 swop/github-webhook 包。

处理传入GitHub webhook请求的库(签名验证 & 有效载荷解析)

v3.1 2020-11-14 10:26 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:03:03 UTC


README

Build Status

此库提供了一系列工具,在处理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 文件。

原始贡献者

许可证

此库在MIT许可证下发布。请参阅捆绑的完整 LICENSE 文件。