Implement webhook inspector
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\WebhookEndpoint;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
Broadcast::channel('App.Models.User.{id}', function (User $user, string $id): bool {
|
||||
return (string) $user->getKey() === $id;
|
||||
});
|
||||
|
||||
Broadcast::channel('webhooks.{endpointId}', function (User $user, string $endpointId): bool {
|
||||
$endpoint = WebhookEndpoint::query()->find($endpointId);
|
||||
|
||||
return $endpoint instanceof WebhookEndpoint
|
||||
&& ! $endpoint->is_public
|
||||
&& (string) $endpoint->user_id === (string) $user->getKey();
|
||||
});
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schedule;
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
||||
Schedule::command('webhooks:prune')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->onOneServer();
|
||||
|
||||
+23
-3
@@ -1,7 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\EndpointController;
|
||||
use App\Http\Controllers\InspectorController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
Route::view('/', 'welcome')->name('home');
|
||||
|
||||
Route::post('/inspectors', [EndpointController::class, 'storeAnonymous'])
|
||||
->name('inspectors.store');
|
||||
|
||||
Route::any('/hook/{token}', [EndpointController::class, 'receive'])
|
||||
->middleware('throttle:webhooks')
|
||||
->where('token', '[A-Za-z0-9]+')
|
||||
->name('webhooks.receive');
|
||||
|
||||
Route::get('/inspect/{token}', [InspectorController::class, 'show'])
|
||||
->where('token', '[A-Za-z0-9]+')
|
||||
->name('inspect.show');
|
||||
|
||||
Route::delete('/inspect/{token}', [EndpointController::class, 'destroy'])
|
||||
->where('token', '[A-Za-z0-9]+')
|
||||
->name('inspect.destroy');
|
||||
|
||||
Route::view('/dashboard', 'dashboard-page')
|
||||
->middleware(['auth', 'verified'])
|
||||
->name('dashboard');
|
||||
|
||||
Reference in New Issue
Block a user