devuniverse/api-user-provider-1

Laravel UserProvider over rest api

v0.2.0 2018-07-10 19:31 UTC

This package is auto-updated.

Last update: 2024-04-24 19:23:50 UTC


README

Install

Add repository to composer.json file.

  "repositories": [
      {
        "type": "vcs",
        "url": "https://github.com/cesg/api-user-provider"
      }
    ]

Add composer dependecie

  composer require cesg/api-user-provider

Configuration

publish the config file

  php artisan vendor:publish --provider="Cesg\Auth\Provider\ApiUserServiceProvider" --tag="config"
return [
    'uri' => env('', 'localhost/api/v1/users'),
    'bearer_token' => env('USER_PROVIDER_API_TOKEN', ''),
    'headers' => []
];

Set the driver in auth config file.

return [
    'providers' => [
              'users' => [
                  'driver' => 'api-users',
                  'model' => Cesg\Auth\Provider\User::class,
              ]
          ],
]

If you use laravel/passport need extend the Cesg\Auth\Provider\User and add the trait Laravel\Passport\HasApiTokens and set the provider model to you own class.

  class User extends \Cesg\Auth\Provider\User
  {
      use HasApiTokens;
  }