PHP code example of qiick / laravel-oidc

1. Go to this page and download the library: Download qiick/laravel-oidc 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/ */

    

qiick / laravel-oidc example snippets


$this->app->bind(UserProvisioningContract::class, ProvisionSsoUserService::class);

'roles' => [
    'enabled' => true,
    'claim' => 'orgs',            // Signaculum with the qiick.orgs scope
    'organization' => 'acme',     // id or slug of the org this app belongs to
    'map' => ['owner' => 'admin', 'admin' => 'admin', 'member' => 'editor'],
    'forbidden' => [],
],

$this->app->bind(SecondFactorChallengeContract::class, SsoSecondFactorChallengeService::class);

Fortify::authenticateUsing(fn (Request $request) => /* ...password check... */ $user !== null && app(SsoOnlyModeService::class)->canUseLocalLogin($user) ? $user : null);
Passkeys::authorizeLoginUsing(fn (Request $request, $user) => /* ... */ app(SsoOnlyModeService::class)->canUseLocalLogin($user));

$identity = app(AuthorizationCodeFlowService::class)->handleCallback($request); // throws an OidcException subclass
$challenge = app(OidcLoginService::class)->login($request, $identity);          // null when signed in, else the 2FA challenge; throws LoginRefusedException

$endSessionUrl = app(RpInitiatedLogoutService::class)->endSessionUrl($request->session()); // null for a local login

Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();

return $endSessionUrl !== null ? redirect()->away($endSessionUrl) : redirect('/');

$this->app->bind(ProviderConfigurationRepositoryContract::class, DatabaseOidcSettingsRepository::class);

use Qiick\Oidc\Testing\FakeIdentityProvider;

$identityProvider = FakeIdentityProvider::fake(); // Http::fake() + config('oidc.*')
$authorizationUrl = $this->get('/auth/oidc/redirect')->headers->get('Location');
$callbackUrl = $identityProvider->authorize($authorizationUrl, ['sub' => 'user-42', 'email' => '[email protected]']);
$this->get($callbackUrl);
bash
composer vendor:publish --tag=oidc-config
php artisan migrate
php artisan oidc:configure --issuer=https://idp.example.com/realms/acme --client-id=my-app --client-secret=...
bash
php artisan migrate   # creates user_identities