Files
Fitness/web/logout.php
T

28 lines
874 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// logout.php
require __DIR__ . '/../vendor/autoload.php';
session_start();
$oidc = new \Jumbojett\OpenIDConnectClient(
'https://auth.matt-cloud.com/oidc',
'fitness-oidc',
'egebuqzZfVnjjBG9JDQ8tjW3TzV9gJurvT7qfB6c2SX2nPBNeaGycDfx4788QzJd'
);
// Build the end‑session endpoint (back‑channel logout)
$logoutUrl = $oidc->getLogoutEndpoint(); // e.g. https://auth.matt-cloud.com/logout
// Include the post‑logout redirect URI
$logoutUrl .= '?post_logout_redirect_uri=' . urlencode('https://fitness.matt-cloud.com/');
// Optionally pass the ID‑token hint so the OP can immediately terminate the session
if (isset($_SESSION['user']['id_token'])) {
$logoutUrl .= '&id_token_hint=' . urlencode($_SESSION['user']['id_token']);
}
// Destroy the local session first
session_destroy();
// Redirect the browser
header('Location: ' . $logoutUrl);
exit;