How to specify auth guard when using multiple guards with Sanctum #preamble Preamble https://laravel.com/docs/sanctum is the go-to solution for token-based API authentication and SPA (Single page application) authentication. It uses an authentication guard when performing the SPA authentication.

If your web app has multiple panels (say, admin, manager, customer, etc)., you'd be using multiple authentication guards.

Assuming that our web app follows this pattern in the API endpoints, we can decide the auth guard dynamically inside the middleware.

//... ]; And with this, your web app should be using the respective auth guard to protect the routes as per the user type.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners