From 7d70bfe8289fce07fa595340578b13f4bdac495d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 18 Dec 2019 13:44:16 -0600 Subject: [PATCH] Utilize Authentication Middleware Contract (#5181) * adjust auth middleware to point to contract * remove middleware priority --- app/Http/Kernel.php | 19 +------------------ app/Providers/AuthServiceProvider.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index deb65e86..d4bc5588 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -51,7 +51,7 @@ class Kernel extends HttpKernel * @var array */ protected $routeMiddleware = [ - 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth' => \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, @@ -62,21 +62,4 @@ class Kernel extends HttpKernel 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ]; - - /** - * The priority-sorted list of middleware. - * - * This forces non-global middleware to always be in the given order. - * - * @var array - */ - protected $middlewarePriority = [ - \Illuminate\Session\Middleware\StartSession::class, - \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \App\Http\Middleware\Authenticate::class, - \Illuminate\Routing\Middleware\ThrottleRequests::class, - \Illuminate\Session\Middleware\AuthenticateSession::class, - \Illuminate\Routing\Middleware\SubstituteBindings::class, - \Illuminate\Auth\Middleware\Authorize::class, - ]; } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 30490683..f82edc3b 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,6 +2,8 @@ namespace App\Providers; +use App\Http\Middleware\Authenticate; +use Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Gate; @@ -16,6 +18,16 @@ class AuthServiceProvider extends ServiceProvider // 'App\Model' => 'App\Policies\ModelPolicy', ]; + /** + * Register any application services. + * + * @return void + */ + public function register() + { + $this->app->bind(AuthenticatesRequests::class, Authenticate::class); + } + /** * Register any authentication / authorization services. *