keycloak
This commit is contained in:
28
public/auth/logout/index.php
Normal file
28
public/auth/logout/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\KeycloakAuth;
|
||||
|
||||
session_start();
|
||||
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
$auth = new KeycloakAuth(ConfigLoader::load($projectRoot, 'keycloak'));
|
||||
$logoutUrl = null;
|
||||
|
||||
if ($auth->isConfigured() && $auth->isAuthenticated()) {
|
||||
$logoutUrl = $auth->logoutUrl();
|
||||
}
|
||||
|
||||
$auth->logout();
|
||||
|
||||
if ($logoutUrl !== null) {
|
||||
header('Location: ' . $logoutUrl, true, 302);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Location: /auth/login', true, 302);
|
||||
exit;
|
||||
Reference in New Issue
Block a user