Protects against unverified webhooks from 3rd party services on Laravel 5.5+
- Supported Laravel 5.5+
- Allow multi services with same driver (Useful for two webhook endpoints of two facebook applications)
- Supported drivers
- Bitbucket
- Github
- Gitlab
- Mailgun
- Shopify
- Trello
- Easy to extend more drivers
- php >=7.1.3
- Laravel 5.5+
Laravel 6.0+ required php 7.2+
Begin by pulling in the package through Composer.
$ composer require oanhnn/laravel-webhook-shield
The package will automatically register itself.
You can publish the config-file with:
$ php artisan vendor:publish --provider=Laravel\WebhookShield\ServiceProvider
In configuration file, you can define services
<?php
return [
'services' => [
'github' => [
'driver' => 'github',
'options' => [],
],
'facebook' => [
'driver' => \Laravel\WebhookShield\Services\Facebook::class,
'options' => [],
],
'custom' => [
'driver' => 'custom-driver',
'options' => [],
],
],
];
Route::middleware('shield:facebook')->post('/webhook/facebook', 'WebhookController@facebook');
Route::middleware('shield:github')->post('/webhook/facebook', 'WebhookController@github');
Route::middleware('shield:custom')->post('/webhook/custom', 'WebhookController@custom');
Make a service implement class
<?php
namespace App\Services;
use Laravel\WebhookShield\Contracts\Service;
class CustomService implements Service
{
// ...
}
And register this driver in app/Providers/AppServiceProvider.php
<?php
namespace App\Providers;
use App\Services\CustomService;
use Illuminate\Support\ServiceProvider;
use Laravel\WebhookShield\Facades\Shield;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Shield::extend('custom-driver', function ($app, $config) {
return new CustomService($config);
});
// ...
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// ...
}
}
See all change logs in CHANGELOG
$ git clone git@github.com/oanhnn/laravel-webhook-shield.git /path
$ cd /path
$ composer install
$ composer phpunit
Please see CONTRIBUTING for details.
If you discover any security related issues, please email to Oanh Nguyen instead of using the issue tracker.
This project is released under the MIT License.
Copyright © 2018-2019 Oanh Nguyen.