-
Notifications
You must be signed in to change notification settings - Fork 0
3.2. Manual configuration
First, you need to publish the heloufir/simple-passport:
php artisan vendor:publish --provider=Heloufir\SimplePassport\SimplePassportServiceProvider
After, you need to publish the heloufir/security-starter:
php artisan vendor:publish --provider=Heloufir\SecurityStarter\SecurityStarterServiceProvider
Then, if you want to customize the profiles, roles, profile_roles and user_profiles tables you need first to update the file config/security-starter.php, then go to next step.
Launch migrations to add laravel/passport tables and heloufir/security-starter tables:
php artisan migrate
Then, install laravel/passport oauth clients, by executing:
php artisan passport:install
Add Laravel\Passport\HasApiTokens trait to the User model
<?php
namespace App;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasApiTokens, Notifiable;
}
Add Heloufir\SecurityStarter\Core\UserProfiles trait to the User model
<?php
namespace App;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Heloufir\SecurityStarter\Core\UserProfiles;
class User extends Authenticatable
{
use HasApiTokens, Notifiable, UserProfiles;
}
Add 'roles' => \Heloufir\SecurityStarter\Http\Middleware\RoleMiddleware::class
to the $routeMiddleware in Kernel
File: app/Http/Kernel.php
protected $routeMiddleware = [
// ...
'roles' => \Heloufir\SecurityStarter\Http\Middleware\RoleMiddleware::class
];
Don't forget to update the guards in your auth.php configuration file for the
api
to passport
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport', // <- Here
'provider' => 'users',
],
],
That's all, the installation and configuration of security-starter is done.