1. Go to this page and download the library: Download dskripchenko/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/ */
use Dskripchenko\Oidc\Exceptions\ProviderError;
try {
$fresh = app(OidcClient::class)->refresh($stored->refreshToken);
// keep $fresh->refreshToken ?? $stored->refreshToken
} catch (ProviderError $e) {
if ($e->reason() === 'refresh_rejected') {
// blocked, signed out or the session ended at the provider: end the session here too
}
// 'refresh': the provider could not answer; try again later
}
use Dskripchenko\Oidc\Http\Middleware\AuthenticateProviderToken;
use Dskripchenko\Oidc\Tokens\ProviderAccessToken;
Route::middleware([AuthenticateProviderToken::class, 'auth:sanctum'])->get('/api/me', function (Request $request) {
$token = ProviderAccessToken::of($request); // null for any other credential
return ['user' => $request->user()->id, 'client' => $token?->client];
});
use Dskripchenko\Oidc\Groups\GroupClaims;
use Dskripchenko\Oidc\Groups\RoleMapping;
GroupClaims::of($claims); // list<string>|null from OIDC_GROUPS_CLAIM
GroupClaims::blocks($groups); // in OIDC_BLOCKED_GROUP?
RoleMapping::pairs(); // OIDC_ROLE_GROUPS="admins=admin,auditors=auditor"
RoleMapping::decide($givingGroups, $groups, $heldFromProvider); // RoleChange|null
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.