this pack help you to provide your user from different service ( useful in micro service )
this package use bearer token in header's request and provide user from Sec Service (Auth service)
Via Composer
$ composer require amin3536/laravel-api-user-provider
simple usage this driver : change your auth.php
in config
like below
<?php
return [
//.......
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'api-token',
'provider' => 'users',
],
'admin-api' => [
'driver' => 'api-token',
'provider' => 'admins',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
*/
'providers' => [
'users' => [
'driver' => 'api-provider',
'model' => App\Models\User::class,
//merged with base_url or you can use full path api here =>http://localhost/api/admin/
'url' => '/api/v1/user/'
],
'admins' => [
'driver' => 'api-provider',
'model' => App\Models\Admin::class,
'url' => '/api/v1/admin/'
],
],
/*
|--------------------------------------------------------------------------
| Base url path to to call Auth Service
|--------------------------------------------------------------------------
|
*/
'base-url'=>'localhost',
'TimeoutForRequestAuthServer'=>2
//.......
];
if you want use custom Deserializer class ,the class must be implement DeserializerInterface
and add below code in boot method of AuthServiceProvider .
<?php
//...
public function boot()
{
$this->app->when(ExternalUserProvider::class)
->needs(DeserializerInterface::class)
->give(function () {
return new JsonToModel();
});
}
Please see the changelog for more information on what has changed recently.
$ composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email author email instead of using the issue tracker.
license. Please see the license file for more information.