azibom / who-are-you
There is no license information available for the latest version (dev-master) of this package.
Laravel api authontication
dev-master
2020-09-23 19:14 UTC
Requires
- laravel/passport: ^9.3
Requires (Dev)
- squizlabs/php_codesniffer: ^3.0@dev
This package is auto-updated.
Last update: 2025-03-24 04:51:59 UTC
README
who-are-you
Laravel api authentication package
Instalation
Step one
Install the package, run the migration, initialize the passport
composer require azibom/who-are-you
php artisan migrate
php artisan passport:install
Step two
- Add the HasApiTokens trait to the user model
<?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Passport\HasApiTokens; class User extends Authenticatable { use Notifiable, HasApiTokens; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; }
- Change the api guard in the config/auth.php
... 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'passport', 'provider' => 'users', ], ], ...
- Add the WHO_ARE_YOU_BASE_URL env var in the .env file of the project
WHO_ARE_YOU_BASE_URL=http://localhost
(If you are using docker for example you should change it with your webserver container's name for example)
WHO_ARE_YOU_BASE_URL=http://nginx