Skip to content

AbdoMoh96/laravel-sanctum-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.

Official Documentation

Documentation for Sanctum can be found on the Laravel website.

installation steps

  • run in command line composer require laravel/sanctum
  • run in command line php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
  • run in command line php artisan migrate
  • Next, if you plan to utilize Sanctum to authenticate an SPA, you should add Sanctum's middleware to your api middleware group within your application's app/Http/Kernel.php file:

    'api' => [ \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, ],
  • in the user model add : "use HasApiTokens" trait class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; }

Info

to protect routes use the 'auth:sanctum' middleware : Route::middleware('auth:sanctum')

for a pre config copy the Auth routes/controller directories

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages