From 4bc983a8eb46b5b6cbf8319fb2813277dbfa8c64 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Sun, 30 Aug 2015 20:17:23 +0200
Subject: [PATCH] Deprecate SimpleSAML_Default::logoutCallback() and move it to
 SimpleSAML_Auth_Source. This also resolves an issue with this callback not
 being called, since SimpleSAML_Auth_Source::initLogin() was expecting the
 method to be inside that class.

---
 lib/SimpleSAML/Auth/Default.php | 20 +++-----------------
 lib/SimpleSAML/Auth/Source.php  | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index 4541f02db..213ab01c3 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -145,25 +145,11 @@ class SimpleSAML_Auth_Default {
 	 * Called when the authentication source receives an external logout request.
 	 *
 	 * @param array $state  State array for the logout operation.
+	 *
+	 * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML_Auth_Source::logoutCallback() instead.
 	 */
 	public static function logoutCallback($state) {
-		assert('is_array($state)');
-		assert('array_key_exists("SimpleSAML_Auth_Default.logoutSource", $state)');
-
-		$source = $state['SimpleSAML_Auth_Default.logoutSource'];
-
-
-		$session = SimpleSAML_Session::getSessionFromRequest();
-		if (!$session->isValid($source)) {
-			SimpleSAML_Logger::warning(
-				'Received logout from an invalid authentication source '.
-				var_export($source, TRUE)
-			);
-
-			return;
-		}
-
-		$session->doLogout($source);
+		SimpleSAML_Auth_Source::logoutCallback($state);
 	}
 
 
diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php
index 4637f8ba7..e6dd85624 100644
--- a/lib/SimpleSAML/Auth/Source.php
+++ b/lib/SimpleSAML/Auth/Source.php
@@ -350,6 +350,31 @@ abstract class SimpleSAML_Auth_Source
     }
 
 
+    /**
+     * Called when the authentication source receives an external logout request.
+     *
+     * @param array $state State array for the logout operation.
+     */
+    public static function logoutCallback($state)
+    {
+        assert('is_array($state)');
+        assert('array_key_exists("SimpleSAML_Auth_Default.logoutSource", $state)');
+
+        $source = $state['SimpleSAML_Auth_Default.logoutSource'];
+
+        $session = SimpleSAML_Session::getSessionFromRequest();
+        if (!$session->isValid($source)) {
+            SimpleSAML_Logger::warning(
+                'Received logout from an invalid authentication source '.
+                var_export($source, true)
+            );
+
+            return;
+        }
+        $session->doLogout($source);
+    }
+
+
     /**
      * Add a logout callback association.
      *
-- 
GitLab