Laravel Jetstream - default fortify or sanctum?

Viewed 37

I've got a fair amount of experience with laravel but I'm new to jetstream - just having a look into it at the moment and I'm confused regarding authentication methods.

I understand there are two main options:

  • Fortify - basic front end agnostic authentication system.
  • Sanctum - Used for SPA's and generating tokens for Api's.

The documentation for jetstream suggests jetstream defaults to using Fortify as its authentication backend. However the default 'web' routes are set up as below:

Route::middleware([
  'auth:sanctum',
  config('jetstream.auth_session'),
  'verified'
])->group(function () {
    
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');

});

Why is 'sanctum' being passed as a parameter to the authentication middleware? Is jetstream actually using sanctum as its default now? From what I can tell Jetstreams registration / authentication pages work just as well if the sanctum parameter isnt passed.

I'm likley getting confused about the differences between fortify & sanctum or how its being implemented in Jetstream.

Any help would be greatly appreciated.

Thanks

1 Answers

Sanctum is just a headless auth system. It provides session cookie- and api token authentication. Jetstream uses it alongside fortify which will register all the routes, controllers, etc.. containing the logic for login, registration, password resets...

Related