Skip to content

Commit

Permalink
TASK: logout without active saml token
Browse files Browse the repository at this point in the history
  • Loading branch information
simstern committed Apr 26, 2023
1 parent 6d42886 commit 845c051
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Classes/Authentication/SimpleSamlAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@ class SimpleSamlAuthentication extends Simple implements AuthenticationInterface
public function logout($params = null)
{
// TODO: Adapt to \Neos\Flow\Security\Authentication\AuthenticationProviderManager::logout() or even call the method directly if possible
$session = $this->sessionManager->getCurrentSession();
$params = is_array($params) ? array_merge($this->logoutParams, $params) : $this->logoutParams;
if ($this->securityContext->getAuthenticationTokensOfType(SamlToken::class)) {
/** Logout will redirect and not return to logout process. Therefore the session is destroyed here.
* @see \Neos\Flow\Security\Authentication\AuthenticationProviderManager::logout() */
if ($session->isStarted()) {
$session->destroy('Logout through SimpleSamlAuthentication');
$tokens = $this->securityContext->getAuthenticationTokensOfType(SamlToken::class);
foreach ($tokens as $token) {
if ($token->isAuthenticated()) {
$session = $this->sessionManager->getCurrentSession();
$logoutParams = array_filter($this->logoutParams);
$params = is_array($params) ? array_merge($logoutParams, $params) : $logoutParams;

/** Logout will redirect and not return to logout process. Therefore the session is destroyed here.
* @see \Neos\Flow\Security\Authentication\AuthenticationProviderManager::logout()
*/
if ($session->isStarted()) {
$session->destroy('Logout through SimpleSamlAuthentication');
}
parent::logout($params);
}
parent::logout($params);
}
}
}

0 comments on commit 845c051

Please sign in to comment.