KnpLabs / KnpLabs/php-github-api
Utility to validate webhook signatures
まだ誰も着手していません。
- 主要言語
- PHP
- スター
- 2.2k
- フォーク
- 585
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I'm not sure this should actually be implemented in this repo, as it is different from other use cases, but maintainers might still decide it fits this repository.
When implementing github webhooks, it is possible to secure them (to reject any fake requests sent to the webhook from elsewhere than Github).
Github sends a signature header in each webhook request. Their documentation shows the Ruby code to validate the request: https://developer.github.com/webhooks/securing/
I suggest providing a utility method which would validate a signature, to avoid having each developer figuring out the corresponding PHP code:
class SignatureChecker
{
function validateSignature(string $signature, string $requestBody, string $secret): bool
{ // TODO implement that
}
}
The naming is not final of course.
I suggest that this API takes the 3 strings as arguments rather than alternatives. Here are the ones I considered but which I consider inferior:
- the secret could be a constructor argument, but this could make things harder if you manage multiple webhooks in your codebase and each of them uses a separate secret (you would have to manage separate instances)
- the signature and body could be replaced by a PSR-7 request, from which they would be extracted. But that would make things harder to use for people using frameworks not relying on PSR-7 (Symfony for instance). Having to convert the request to PSR-7 just to check the signature is adding unnecessary overhead (getting the request body and a header are easy enough to be left to the calling code)
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
このissueでは SignatureChecker::validateSignature(string $signature, string $requestBody, string $secret) エントリーポイントが提案されていますが、対象ファイルもテストも指定されていません。まず、webhook署名の検証がこのrepositoryに属するものかどうか、また既存のutilityがどのように整理されているかを確認してください。maintainerがAPIに合意し、文書化された署名検証の動作をカバーする形でutilityが実装されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- github, php
- 領域
- api, security
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100