OIDC test - test jumbojett oidc round two change root paths
This commit is contained in:
1 parent
4b7abac7ca
commit
07d3895eb5
6 files changed
+6
-6
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
use Jumbojett\OpenIDConnectClient;
|
||||
|
||||
session_start();
|
||||
$config = require __DIR__ . '/../config.php';
|
||||
|
||||
$oidc = new OpenIDConnectClient(
|
||||
$config['provider_url'],
|
||||
$config['client_id'],
|
||||
$config['client_secret']
|
||||
);
|
||||
$oidc->setRedirectURL($config['redirect_uri']);
|
||||
$oidc->addScope($config['scopes']);
|
||||
$oidc->setResponseTypes([$config['response_type']]);
|
||||
|
||||
// This will read the `code` query parameter, fetch the tokens
|
||||
// and validate everything.
|
||||
$oidc->authenticate();
|
||||
|
||||
|
||||
// Fetch the OpenID Connect userinfo claims
|
||||
$claims = $oidc->requestUserInfo(); // → stdClass with the claims
|
||||
|
||||
// Store what we need in the PHP session
|
||||
$_SESSION['authenticated'] = true;
|
||||
$_SESSION['name'] = $claims->name ?? $claims->given_name ?? $claims->family_name ?? '';
|
||||
$_SESSION['email'] = $claims->email ?? '';
|
||||
$_SESSION['groups'] = $claims->groups ?? [];
|
||||
|
||||
// Redirect back to the home page
|
||||
header('Location: ../');
|
||||
exit;
|
||||
Reference in new issue
Block a user