lemonphp/webhook-shield

保护免受第三方服务未经验证的webhook攻击

v1.0.0 2019-10-17 10:07 UTC

This package is auto-updated.

Last update: 2024-09-17 21:56:23 UTC


README

Latest Version Software License Build Status Coverage Status Total Downloads Requires PHP

保护免受第三方服务未经验证的webhook攻击。

特性

  • 兼容PSR-7、PSR-15和PSR-17
  • 无依赖
  • 支持驱动
    • Bitbucket
    • Facebook
    • Github
    • Gitlab
    • Mailgun
    • Shopify
    • Trello
  • 遵循 PSR-2PSR-4 编码风格

需求

  • php >=7.1

安装

首先通过Composer引入包。

$ composer require lemonphp/webhook-shield

使用方法

Slim 4

  1. 安装Slim应用程序,请参考链接 https://slim.php.ac.cn/docs/v4/start/installation.html

    $ composer require slim/slim slim/psr7 lemonphp/webhook-shield
  2. 创建 public/index.php 并包含以下内容

    <?php
    use Lemon\WebhookShield\ServiceProfiles\Facebook;
    use Lemon\WebhookShield\WebhookShieldMiddleware;
    use Psr\Http\Message\ResponseInterface as Response;
    use Psr\Http\Message\ServerRequestInterface as Request;
    use Slim\Factory\AppFactory;
    
    require __DIR__ . '/../vendor/autoload.php';
    
    $app = AppFactory::create();
    
    $shield = new WebhookShieldMiddleware(new Facebook('secret'), $app->getResponseFactory());
    
    $app->post('/webhook/facebook', function (Request $req, Response $res, $args) {
         // TODO: Add webhook event to message queue
         return $res->withStatus(200, 'OK');
    })->add($shield);
    
    // other routes
    
    $app->run();

变更日志

查看所有变更日志 CHANGELOG

测试

$ git clone git@github.com/lemonphp/webhook-shield.git /path
$ cd /path
$ composer install
$ composer test

贡献

请参阅 CONTRIBUTING 以获取详细信息。

安全

如果您发现任何安全相关的问题,请通过电子邮件发送至 Oanh Nguyen 而不是使用问题跟踪器。

鸣谢

许可协议

本项目发布于MIT许可协议下。
版权 © 2019 LemonPHP 团队。