Skip to content

Commit fd63b96

Browse files
authored
Merge pull request #5274 from Roardom/fix-middleware-aliases
(Fix) Fortify hardcoding middleware aliases
2 parents 6160f12 + 3bc4129 commit fd63b96

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/Http/Kernel.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use App\Http\Middleware\BlockIpAddress;
2222
use App\Http\Middleware\UpdateLastAction;
2323
use HDVinnie\SecureHeaders\SecureHeadersMiddleware;
24+
use Illuminate\Auth\Middleware\RedirectIfAuthenticated;
2425
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
2526
use Illuminate\Cookie\Middleware\EncryptCookies;
2627
use Illuminate\Routing\Middleware\ThrottleRequestsWithRedis;
@@ -98,4 +99,16 @@ class Kernel extends HttpKernel
9899
ThrottleRequestsWithRedis::class.':'.GlobalRateLimit::RSS->value,
99100
],
100101
];
102+
103+
/**
104+
* The application's route middleware.
105+
*
106+
* These middleware may be assigned to groups or used individually.
107+
*
108+
* @var array<string, class-string>
109+
*/
110+
protected $middlewareAliases = [
111+
'guest' => RedirectIfAuthenticated::class,
112+
'throttle' => ThrottleRequestsWithRedis::class,
113+
];
101114
}

config/fortify.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
|
9393
*/
9494

95-
'middleware' => [MiddlewareGroup::WEB->value],
95+
'middleware' => [MiddlewareGroup::WEB->value],
96+
'auth_middleware' => Illuminate\Auth\Middleware\Authenticate::class,
9697

9798
/*
9899
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)