Skip to content

Latest commit

 

History

History
61 lines (52 loc) · 1.44 KB

AUTH.md

File metadata and controls

61 lines (52 loc) · 1.44 KB

Implementing Auth

This method should typically be called in the boot method of your AuthServiceProvider class:

use Bitinflow\Accounts\BitinflowAccounts;
use Bitinflow\Accounts\Providers\BitinflowAccountsSsoUserProvider;
use Illuminate\Http\Request;

/**
 * Register any authentication / authorization services.
 *
 * @return void
 */
public function boot()
{
    Auth::provider('sso-users', function ($app, array $config) {
        return new BitinflowAccountsSsoUserProvider(
            $app->make(BitinflowAccounts::class),
            $app->make(Request::class),
            $config['model'],
            $config['fields'] ?? [],
            $config['access_token_field'] ?? null
        );
    });
}

reference the guard in the guards configuration of your auth.php configuration file:

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'bitinflow-accounts',
        'provider' => 'sso-users',
    ],
],

reference the provider in the providers configuration of your auth.php configuration file:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],
    
    'sso-users' => [
        'driver' => 'sso-users',
        'model' => App\Models\User::class,
        'fields' => ['first_name', 'last_name', 'email'],
        'access_token_field' => 'sso_access_token',
    ],
],