2017 © Pedro Peláez
 

library github-webhook-middleware

PSR-7 style & PSR-15 compatible middleware which will verify if the incoming GitHub web hook request is correctly signed.

image

swop/github-webhook-middleware

PSR-7 style & PSR-15 compatible middleware which will verify if the incoming GitHub web hook request is correctly signed.

  • Tuesday, November 22, 2016
  • by Swop
  • Repository
  • 1 Watchers
  • 0 Stars
  • 35 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Github WebHook PSR-7 / PSR-15 middleware

Build
Status, (*1)

This library offers a PSR-7 style & PSR-15 middleware which will verify if the incoming GitHub web hook request is correctly signed., (*2)

The provided PSR-7 request will have its X-Hub-Signature header checked in order to see if the request was originally performed by GitHub using the correct secret to sign the request., (*3)

If the request signature validation fails, a 401 JSON response will be send back., (*4)

Installation

The recommended way to install this library is through Composer:, (*5)

composer require "swop/github-webhook-middleware"

Usage

Ex: PSR-7 style middleware using Zend Diactoros Server

```php <?php, (*6)

use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface;, (*7)

use Swop\GitHubWebHook\Security\SignatureValidator; use Swop\GitHubWebHookMiddleware\GithubWebHook;, (*8)

$request = \Zend\Diactoros\ServerRequestFactory::fromGlobals();, (*9)

$middleware = new GithubWebHook(new SignatureValidator(), 'my_secret');, (*10)

$next = function (RequestInterface $request, ResponseInterface $response) { // The security has been check. // Do some stuff with the web hook... return new \Zend\Diactoros\Response\JsonResponse(['status' => 'ok']); };, (*11)

$server = \Zend\Diactoros\Server::createServerFromRequest($middleware, $request);, (*12)

$server->listen($next);, (*13)


### Ex: PSR-15 middleware using Zend Stratigility ````php <?php use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Zend\Stratigility\MiddlewarePipe; use Zend\Stratigility\NoopFinalHandler; use Zend\Diactoros\Server; use Zend\Diactoros\Response\JsonResponse; use Swop\GitHubWebHook\Security\SignatureValidator; use Swop\GitHubWebHookMiddleware\GithubWebHook; $app = (new MiddlewarePipe()) ->pipe(new GithubWebHook(new SignatureValidator(), 'my_secret')) ->pipe('/', function (RequestInterface $request, ResponseInterface $response) { // The security has been check. // Do some stuff with the web hook... return new JsonResponse(['status' => 'OK']); }); $request = \Zend\Diactoros\ServerRequestFactory::fromGlobals(); Server::createServerFromRequest($app, $request) ->listen(new NoopFinalHandler()) ;

Contributing

See CONTRIBUTING file., (*14)

Original Credits

License

This library is released under the MIT license. See the complete license in the bundled LICENSE file., (*15)

The Versions

22/11 2016

1.0.x-dev

1.0.9999999.9999999-dev

PSR-7 style & PSR-15 compatible middleware which will verify if the incoming GitHub web hook request is correctly signed.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware security psr7 github webhook

22/11 2016

dev-master

9999999-dev

PSR-7 style & PSR-15 compatible middleware which will verify if the incoming GitHub web hook request is correctly signed.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware security psr7 github webhook

22/11 2016

v1.0

1.0.0.0

PSR-7 style & PSR-15 compatible middleware which will verify if the incoming GitHub web hook request is correctly signed.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware security psr7 github webhook