Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions src/HybridAuthLoginExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,35 @@ private static function GetProviderName()
*/
public function LogoutAction()
{
if (utils::StartsWith(Session::Get('login_mode'), 'hybridauth-')) {
$oAuthAdapter = self::ConnectHybridAuth();
// Does not redirect...
// and actually just clears the session variable,
// almost useless we can log again without any further user interaction
// At least it disconnects from iTop
$oAuthAdapter->disconnect();
}
$loginMode = Session::Get('login_mode');
if ($loginMode === 'hybridauth-Keycloak')
{
// Allow a clean logout with Keycloak
$oAuthAdapter = self::ConnectHybridAuth();
$providers = Config::Get('providers');

$keycloakServer = $providers['Keycloak']['url'];
$realmName = $providers['Keycloak']['realm'];
$clientId = $providers['Keycloak']['keys']['id'];

$redirectUri = utils::GetAbsoluteUrlAppRoot().'pages/UI.php';
$logoutUrl = "{$keycloakServer}/realms/{$realmName}/protocol/openid-connect/logout?post_logout_redirect_uri={$redirectUri}&client_id={$clientId}";

// Disconnection from iTop
$oAuthAdapter->disconnect();

// Redirection to Keycloak
header("Location: $logoutUrl");
}
else if (utils::StartsWith($loginMode, 'hybridauth-'))
{
$oAuthAdapter = self::ConnectHybridAuth();
// Does not redirect...
// and actually just clears the session variable,
// almost useless we can log again without any further user interaction
// At least it disconnects from iTop
$oAuthAdapter->disconnect();
}
}

private function DoUserProvisioning(string $sLoginMode)
Expand Down