PHP code example of ronu / laravel-federated-auth

1. Go to this page and download the library: Download ronu/laravel-federated-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ronu / laravel-federated-auth example snippets


'authorization_params' => [
    'prompt' => env('FEDERATED_AUTH_GOOGLE_PROMPT'),
],

// routes/admin.php — the default cannot be overridden by a request field.
Route::get('/auth/google/login', [SignInController::class, 'redirect'])
    ->defaults('trusted_channel', 'admin');

$context = AuthContext::fromTrustedRoute('google', $request, [
    // Values your application derives server-side. NOT a way to pass request
    // input back in.
    'redirect_uri' => $this->policy->callbackUri($channel),
    'metadata' => ['federated_login_only' => true],
]);

$state = $this->states->consume('google', $incomingState, $request);

$state->assertMatches([
    'channel' => 'admin',
    'metadata' => ['federated_login_only' => true],
    'metadata_absent' => ['registration_type'],
]);

// config/federated-auth.php
'error_reporting' => [
    'enabled' => true,
    'handlers' => [
        App\Jobs\LogErrorToDatabase::class,   // a queued job: gets the payload array
        // 'App\Services\ErrorLogService@store',             // an existing service
        // App\Reporting\ErrorLogReporter::class,            // an ErrorReporterInterface
    ],
    'queue' => ['queue' => 'logs', 'after_response' => true],
],
bash
php artisan vendor:publish --tag=federated-auth-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=federated-auth-docs