From 5a4ded6ef07a2041f4d74bd7e1c49b6973454a84 Mon Sep 17 00:00:00 2001 From: Finn Paes Date: Tue, 27 Feb 2024 15:47:55 +0100 Subject: [PATCH] Add Laravel Nova authentication middleware to API routes --- readme.md | 2 +- src/AdvancedNovaMediaLibraryServiceProvider.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 08b9b7a9..6498e24d 100644 --- a/readme.md +++ b/readme.md @@ -117,7 +117,7 @@ public function fields(Request $request) If you upload the same media files to multiple models and you do not want to select it from the file system all over again, use this feature. Selecting an already existing media will **copy it**. -**Attention**: This feature will expose an endpoint to every user of your application to search existing media. +**Attention**: This feature will expose an endpoint to every Nova authenticated user of your application to search existing media. If your media upload / custom properties on the media models are confidential, **do not enable this feature!** * Publish the config files if you did not yet diff --git a/src/AdvancedNovaMediaLibraryServiceProvider.php b/src/AdvancedNovaMediaLibraryServiceProvider.php index 3e9d0d36..7ab0ef75 100644 --- a/src/AdvancedNovaMediaLibraryServiceProvider.php +++ b/src/AdvancedNovaMediaLibraryServiceProvider.php @@ -6,6 +6,7 @@ use Laravel\Nova\Nova; use Laravel\Nova\Events\ServingNova; use Illuminate\Support\ServiceProvider; +use Laravel\Nova\Http\Middleware\Authenticate; class AdvancedNovaMediaLibraryServiceProvider extends ServiceProvider { @@ -33,7 +34,7 @@ protected function routes() return; } - Route::middleware(['nova']) + Route::middleware(['nova', Authenticate::class]) ->prefix('nova-vendor/ebess/advanced-nova-media-library') ->group(__DIR__.'/../routes/api.php'); }