From ed84050cc48fb41693ad41c9e7ea17fa0f2ffa86 Mon Sep 17 00:00:00 2001 From: Lapotor <17144397+Lapotor@users.noreply.github.com> Date: Thu, 14 Dec 2023 07:13:04 +0100 Subject: [PATCH] feat: add `PermissionsMiddleware` as `permission` alias (#77) Introduce `PermissionsMiddleware` using the `permission` alias from the [`spatie/laravel-permission`](https://github.com/spatie/laravel-permission) package. Set middleware priorities for improved execution order. Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- app/Http/Kernel.php | 22 ++++++++++++++++++++++ app/Permissions/.gitkeep | 0 2 files changed, 22 insertions(+) create mode 100644 app/Permissions/.gitkeep diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 7c532850..0b418b81 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -65,5 +65,27 @@ class Kernel extends HttpKernel 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class, + ]; + + /** + * The priority-sorted list of middleware. + * + * This forces non-global middleware to always be in the given order. + * + * @var string[] + */ + protected $middlewarePriority = [ + \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, + \Illuminate\Cookie\Middleware\EncryptCookies::class, + \Illuminate\Session\Middleware\StartSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, + \Illuminate\Routing\Middleware\ThrottleRequests::class, + \Illuminate\Routing\Middleware\ThrottleRequestsWithRedis::class, + \Illuminate\Contracts\Session\Middleware\AuthenticatesSessions::class, + \Spatie\Permission\Middleware\PermissionMiddleware::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + \Illuminate\Auth\Middleware\Authorize::class, ]; } diff --git a/app/Permissions/.gitkeep b/app/Permissions/.gitkeep new file mode 100644 index 00000000..e69de29b