From 244ffb245003a7c5e52beda63a81c934bcf9f663 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 29 Dec 2023 08:35:54 +0100 Subject: [PATCH] Start throwing 404's --- app/Http/Controllers/Webhooks/CreateController.php | 4 ++++ app/Http/Controllers/Webhooks/DeleteController.php | 8 ++++++-- app/Http/Controllers/Webhooks/EditController.php | 4 ++++ app/Http/Controllers/Webhooks/IndexController.php | 4 ++++ app/Http/Controllers/Webhooks/ShowController.php | 4 ++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Webhooks/CreateController.php b/app/Http/Controllers/Webhooks/CreateController.php index b61f5e8eb8..8b94a92066 100644 --- a/app/Http/Controllers/Webhooks/CreateController.php +++ b/app/Http/Controllers/Webhooks/CreateController.php @@ -28,6 +28,7 @@ use FireflyIII\Http\Controllers\Controller; use Illuminate\Contracts\View\Factory; use Illuminate\Support\Facades\Log; use Illuminate\View\View; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class CreateController @@ -59,6 +60,9 @@ class CreateController extends Controller public function index() { Log::channel('audit')->info('User visits webhook create page.'); + if(false === config('firefly.allow_webhooks')) { + throw new NotFoundHttpException('Webhooks are not enabled.'); + } $previousUrl = $this->rememberPreviousUrl('webhooks.create.url'); return view('webhooks.create', compact('previousUrl')); diff --git a/app/Http/Controllers/Webhooks/DeleteController.php b/app/Http/Controllers/Webhooks/DeleteController.php index 745891a143..d4fcf29aac 100644 --- a/app/Http/Controllers/Webhooks/DeleteController.php +++ b/app/Http/Controllers/Webhooks/DeleteController.php @@ -29,6 +29,7 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Log; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class DeleteController @@ -60,9 +61,12 @@ class DeleteController extends Controller * * @return Application|Factory|View */ - public function index(Webhook $webhook) - { + public function index(Webhook $webhook) { + Log::channel('audit')->info('User visits webhook delete page.'); + if(false === config('firefly.allow_webhooks')) { + throw new NotFoundHttpException('Webhooks are not enabled.'); + } $subTitle = (string)trans('firefly.delete_webhook', ['title' => $webhook->title]); $this->rememberPreviousUrl('webhooks.delete.url'); diff --git a/app/Http/Controllers/Webhooks/EditController.php b/app/Http/Controllers/Webhooks/EditController.php index bc914d5e7d..c122a60291 100644 --- a/app/Http/Controllers/Webhooks/EditController.php +++ b/app/Http/Controllers/Webhooks/EditController.php @@ -29,6 +29,7 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Log; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class EditController @@ -62,6 +63,9 @@ class EditController extends Controller public function index(Webhook $webhook) { Log::channel('audit')->info('User visits webhook edit page.'); + if(false === config('firefly.allow_webhooks')) { + throw new NotFoundHttpException('Webhooks are not enabled.'); + } $subTitle = (string)trans('firefly.edit_webhook', ['title' => $webhook->title]); $this->rememberPreviousUrl('webhooks.edit.url'); diff --git a/app/Http/Controllers/Webhooks/IndexController.php b/app/Http/Controllers/Webhooks/IndexController.php index 3790e98efa..c1e58ae82f 100644 --- a/app/Http/Controllers/Webhooks/IndexController.php +++ b/app/Http/Controllers/Webhooks/IndexController.php @@ -28,6 +28,7 @@ use FireflyIII\Http\Controllers\Controller; use Illuminate\Contracts\View\Factory; use Illuminate\Support\Facades\Log; use Illuminate\View\View; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class IndexController @@ -55,6 +56,9 @@ class IndexController extends Controller public function index() { Log::channel('audit')->info('User visits webhook index page.'); + if(false === config('firefly.allow_webhooks')) { + throw new NotFoundHttpException('Webhooks are not enabled.'); + } return view('webhooks.index'); } diff --git a/app/Http/Controllers/Webhooks/ShowController.php b/app/Http/Controllers/Webhooks/ShowController.php index e3f9416c18..04c91333cd 100644 --- a/app/Http/Controllers/Webhooks/ShowController.php +++ b/app/Http/Controllers/Webhooks/ShowController.php @@ -29,6 +29,7 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Log; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class ShowController @@ -62,6 +63,9 @@ class ShowController extends Controller public function index(Webhook $webhook) { Log::channel('audit')->info(sprintf('User visits webhook #%d page.', $webhook->id)); + if(false === config('firefly.allow_webhooks')) { + throw new NotFoundHttpException('Webhooks are not enabled.'); + } $subTitle = (string)trans('firefly.show_webhook', ['title' => $webhook->title]); return view('webhooks.show', compact('webhook', 'subTitle'));