Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Thomas_Shelby's avatar

Where is the Auth Middleware in Laravel 12?

I've been using Laravel since version 8, and it's been a great experience up to Laravel 11. Now that Laravel 12 is here, I decided to start my new project using it. However, I noticed some changes that took me by surprise.

First, the default starter kit with Vue now uses ShadCN, which is fine, though I personally didn’t want it. Additionally, it uses TypeScript instead of regular JavaScript. I haven't worked with TypeScript before, but I see it as a good opportunity to explore something new. That said, integrating it into my project has been a bit tricky, but I’m confident I'll get comfortable with it eventually.

Now, my main question: Where is the auth middleware in Laravel 12?

In previous versions, we had an Authenticate middleware inside the app/Http/Middleware/ directory. But in Laravel 12, my Middleware directory only contains HandleAppearance.php and HandleInertiaRequests.php.

I also tried running:

php artisan config:publish auth

However, all the auth-related files were already present. So, how can I find and modify the authentication middleware in Laravel 12?

If anyone has insights into how authentication is handled in Laravel 12 or where to locate the middleware, I'd appreciate the guidance!

0 likes
5 replies
Tray2's avatar

It seems to be here Illuminate\Auth\Middleware

Thomas_Shelby's avatar

I wanted to redirect users to my own route instead of the default login page. To achieve this, I added the following in my AppServiceProvider

use Illuminate\Auth\Middleware\Authenticate;

public function boot(): void { Authenticate::redirectUsing(function ($request) { return route('your.route'); // Change to your desired route }); }

Thanks, Tray! Your suggestion helped me solve this. 😊

1 like
AmadulHaque's avatar

Laravel 12 uses the Authenticatable guard system (via config/auth.php) — same as previous versions — but integrates more tightly with the new bootstrap-based middleware pipeline introduced in v11.

bootstrap/app.php

use App\Http\Middleware\Authenticate; use Illuminate\Session\Middleware\StartSession;

return Application::configure(basePath: dirname(DIR)) ->withMiddleware(function (Middleware $middleware) { $middleware->web(append: [ StartSession::class, Authenticate::class, ]);

    $middleware->redirectGuestsTo('/admin/login');
    $middleware->redirectUsersTo('/admin/dashboard');
})
->create();

They define global redirect rules for:

redirectGuestsTo() → where unauthenticated users go (instead of redirectTo() inside Authenticate.php)

redirectUsersTo() → where authenticated users get redirected when accessing guest-only routes (like /login or /register)

Please or to participate in this conversation.