← Laravel learning path
Laravel · Module 8 of 10

Authentication and authorisation

Add login with starter kits, then control access with gates and policies.

📖 Key ideas

  1. Starter kits like Laravel Breeze add login, register and reset pages.
  2. auth middleware protects routes: ->middleware("auth").
  3. Auth::user() returns the current user.
  4. Gates and Policies decide what users can do.
  5. Sanctum provides API tokens and SPA auth.
💡 Real-life example: Policies are rulebooks per object: who may edit this post? Only its author or an admin.
BreezeSimple auth starter kit
auth middlewareRequires login
PolicyAuthorisation rules for a model
SanctumAPI token authentication