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
35 changes: 23 additions & 12 deletions modules/saml/lib/IdP/SAML2.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ public static function sendResponse(array $state): void
$assertion->setAuthenticatingAuthority($state['saml:AuthenticatingAuthority']);
}

// create the session association (for logout)
$association = [
'id' => 'saml:' . $spEntityId,
'Handler' => '\SimpleSAML\Module\saml\IdP\SAML2',
'Expires' => $assertion->getSessionNotOnOrAfter(),
'saml:entityID' => $spEntityId,
'saml:NameID' => $state['saml:idp:NameID'],
'saml:SessionIndex' => $assertion->getSessionIndex(),
];
$noSession = isset($state['as:NoSession']) && $state['as:NoSession'];
// if current AuthenticationSource says no session: do not to be released to SP (no SLO)
if (!$noSession) {
// create the session association (for logout)
$association = [
'id' => 'saml:' . $spEntityId,
'Handler' => '\SimpleSAML\Module\saml\IdP\SAML2',
'Expires' => $assertion->getSessionNotOnOrAfter(),
'saml:entityID' => $spEntityId,
'saml:NameID' => $state['saml:idp:NameID'],
'saml:SessionIndex' => $assertion->getSessionIndex(),
];
}

// maybe encrypt the assertion
$assertion = self::encryptAssertion($idpMetadata, $spMetadata, $assertion);
Expand All @@ -100,8 +104,11 @@ public static function sendResponse(array $state): void
$ar->setRelayState($relayState);
$ar->setAssertions([$assertion]);

// register the session association with the IdP
$idp->addAssociation($association);
// if current AuthenticationSource says no session to be released to SP (no SLO)
if (!$noSession) {
// register the session association with the IdP
$idp->addAssociation($association);
}

$statsData = [
'spEntityID' => $spEntityId,
Expand Down Expand Up @@ -1146,7 +1153,11 @@ private static function buildAssertion(
$a->setSessionNotOnOrAfter($sessionStart + $sessionLifetime);

$randomUtils = new Utils\Random();
$a->setSessionIndex($randomUtils->generateID());
$noSession = isset($state['as:NoSession']) && $state['as:NoSession'];
// if current AuthenticationSource says no session to be released to SP (no SLO)
if (!$noSession) {
$a->setSessionIndex($randomUtils->generateID());
}

$sc = new SubjectConfirmation();
$scd = new SubjectConfirmationData();
Expand Down