From 853315a8d9c06f69ec9b4a3249bbdc313a7337c6 Mon Sep 17 00:00:00 2001 From: Benjamin Crozat Date: Wed, 25 Oct 2023 08:40:14 +0200 Subject: [PATCH] WIP --- app/Providers/HorizonServiceProvider.php | 8 +++++++- config/cors.php | 4 +++- config/horizon.php | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Providers/HorizonServiceProvider.php b/app/Providers/HorizonServiceProvider.php index d737e6eb..43884f83 100644 --- a/app/Providers/HorizonServiceProvider.php +++ b/app/Providers/HorizonServiceProvider.php @@ -9,6 +9,12 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider { protected function gate() : void { - Gate::define('viewHorizon', fn () => true); + Gate::define('viewHorizon', function ($user = null) { + if (request()->bearerToken() && request()->bearerToken() === config('services.horizon.token')) { + return true; + } + + return 1 === $user->id; + }); } } diff --git a/config/cors.php b/config/cors.php index 9a2fcfb4..2df3badc 100644 --- a/config/cors.php +++ b/config/cors.php @@ -14,7 +14,9 @@ | */ - 'paths' => ['api/*', 'sanctum/csrf-cookie'], + 'paths' => [ + 'horizon/*', + ], 'allowed_methods' => ['*'], diff --git a/config/horizon.php b/config/horizon.php index d32f4eaa..92ca7523 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -215,4 +215,6 @@ ], ], ], + + 'token' => env('HORIZON_TOKEN'), ];