compwright/x-hub-signature
最新稳定版本:v1.0.0
Composer 安装命令:
composer require compwright/x-hub-signature
包简介
X-Hub-Signature webhook signing utility for PHP
README 文档
README
X-Hub-Signature is a compact way to validate webhooks from Facebook, GitHub, or any other source that uses this signature scheme.
Care has been taken to avoid security issues, including timing attacks.
Getting Started
To install:
composer require compwright/x-hub-signature
Usage
Sign a buffer containing a request body:
<?php use Compwright\XHubSignature; use InvalidArgumentException; $signer = new XHubSignature\Sha256(); // Generate the signature header for an outbound webhook, i.e. // // X-Hub-Signature-256: sha256=... // $headerName = $signer->getHeaderName(); $headerValue = $signer->sign($requestBody, $secret); $signatureHeader = $headerName . ': ' . $headerValue; // Verify an inbound webhook $isValid = $signer->verify($signatureHeaderValue, $requestBody, $secret); if ($isValid === false) { throw new InvalidArgumentException('Bad Request'); }
License
MIT License
统计信息
- 总下载量: 6.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-09