From 8645de2aa99f9369bed4df099ee7952c91ce1d26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Fri, 9 Jan 2009 12:40:40 +0000
Subject: [PATCH] Fix for iframe SLO without javascript fallback

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1116 44740490-163a-0410-bde0-09ae8108e29a
---
 .../SingleLogoutServiceiFrameNoJavascript.php    | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php b/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php
index e7035c546..8fa0eb9c4 100644
--- a/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php
+++ b/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php
@@ -48,7 +48,21 @@ $session = SimpleSAML_Session::getInstance();
 $idpentityid = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
 
 
-if ($session->sp_logout_completed() === TRUE) {
+
+$templistofsps = $session->get_sp_list(SimpleSAML_Session::STATE_ONLINE);
+$listofsps = array();
+foreach ($templistofsps AS $spentityid) {
+	if (!empty($_COOKIE['spstate-' . sha1($spentityid)])) $listofsps[] = $spentityid;
+}
+
+
+if (count($templistofsps) === count($listofsps)) {
+
+	$templistofsps = $session->get_sp_list(SimpleSAML_Session::STATE_ONLINE);
+	foreach ($templistofsps AS $spentityid) {
+		$session->set_sp_logout_completed($spentityid);
+		setcookie('spstate-' . sha1($spentityid) , '', time() - 3600); // Delete cookie
+	}
 
 
 	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-- 
GitLab