Installation
This package is specially for lumen micro auth service client app.
$ composer require ackosoft/auth-adapter
Create config folder in your root directory. then add the following code into config/auth.php
<?php
return [
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
'guards' => [
'api' => [
'driver' => 'passport',
'provider' => 'users'
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => \App\User::class
]
],
'auth_connection'=>env('AUTH_DB_CONNECTION','mysql')
];
If you use seperate mysql connection for Passport Authentication so you can do it by chaning env variable. Example:
AUTH_DB_CONNECTION=mysql2
Modify bootstrap/app.php file for enabling the package
$app->withFacades();
$app->withEloquent();
$app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(\Ackosoft\AuthAdapter\AppServiceProvider::class);
$app->routeMiddleware([
'auth' => \Ackosoft\AuthAdapter\Middleware\AuthMiddleware::class,
]);
$app->configure('auth');
Make sure your user model uses Passport's HasApiTokens trait, eg.:
class User extends Model implements AuthenticatableContract, AuthorizableContract
{
use HasApiTokens, Authenticatable, Authorizable;
}
If you use seprate database for authentication so add the connection in User model
protected $connection = 'mysql2';
Todos
License
MIT