From 704c6dc83a92ae0664a3f56f1194f3db7d96e47c Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Mon, 31 Aug 2015 15:15:02 +0200 Subject: [PATCH] Take back the migration of SimpleSAML_Auth_Default::initLogout(), initLogoutReturn() and logoutCompleted(), as they are not used anywhere. We'll just deprecate them and remove them in 2.0 then. --- lib/SimpleSAML/Auth/Default.php | 39 ++++++++++++++++---- lib/SimpleSAML/Auth/Source.php | 65 --------------------------------- 2 files changed, 31 insertions(+), 73 deletions(-) diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php index e2946c059..c3c5c0715 100644 --- a/lib/SimpleSAML/Auth/Default.php +++ b/lib/SimpleSAML/Auth/Default.php @@ -47,25 +47,48 @@ class SimpleSAML_Auth_Default { * @deprecated This method will be removed in SSP 2.0. */ public static function initLogoutReturn($returnURL, $authority) { - $as = self::getAuthSource($authority); - $as->initLogoutReturn($returnURL); - } + assert('is_string($returnURL)'); + assert('is_string($authority)'); + + $session = SimpleSAML_Session::getSessionFromRequest(); + + $state = $session->getAuthData($authority, 'LogoutState'); + $session->doLogout($authority); + + $state['SimpleSAML_Auth_Default.ReturnURL'] = $returnURL; + $state['LogoutCompletedHandler'] = array(get_class(), 'logoutCompleted'); + + $as = SimpleSAML_Auth_Source::getById($authority); + if ($as === NULL) { + /* The authority wasn't an authentication source... */ + self::logoutCompleted($state); + } + + $as->logout($state); + } /** - * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML_Auth_Source::initLogout() instead. + * @deprecated This method will be removed in SSP 2.0. */ public static function initLogout($returnURL, $authority) { - $as = self::getAuthSource($authority); - $as->initLogout($returnURL); + assert('is_string($returnURL)'); + assert('is_string($authority)'); + + self::initLogoutReturn($returnURL, $authority); + + \SimpleSAML\Utils\HTTP::redirectTrustedURL($returnURL); } /** - * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML_Auth_Source::logoutCompleted() instead. + * @deprecated This method will be removed in SSP 2.0. */ public static function logoutCompleted($state) { - SimpleSAML_Auth_Source::logoutCompleted($state); + assert('is_array($state)'); + assert('array_key_exists("SimpleSAML_Auth_Default.ReturnURL", $state)'); + + \SimpleSAML\Utils\HTTP::redirectTrustedURL($state['SimpleSAML_Auth_Default.ReturnURL']); } diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php index 891ac6bc7..9009fb100 100644 --- a/lib/SimpleSAML/Auth/Source.php +++ b/lib/SimpleSAML/Auth/Source.php @@ -247,71 +247,6 @@ abstract class SimpleSAML_Auth_Source } - /** - * Start logout. - * - * This function starts a logout operation from the current authentication source. This function will return if the - * logout operation does not require a redirect. - * - * @param string $returnURL The URL we should redirect the user to after logging out. No checking is performed on - * the URL, so make sure to verify it on beforehand if the URL is obtained from user input. Refer to - * \SimpleSAML\Utils\HTTP::checkURLAllowed() for more information. - */ - public function initLogoutReturn($returnURL) - { - assert('is_string($returnURL)'); - assert('is_string($authority)'); - - $session = SimpleSAML_Session::getSessionFromRequest(); - - $state = $session->getAuthData($this->authId, 'LogoutState'); - $session->doLogout($this->authId); - - $state['SimpleSAML_Auth_Default.ReturnURL'] = $returnURL; - $state['LogoutCompletedHandler'] = array(get_class(), 'logoutCompleted'); - - $this->logout($state); - - self::logoutCompleted($state); - } - - - /** - * Start logout. This method starts a logout operation from the current authentication source. - * - * This method never returns. - * - * @param string $returnURL The URL we should redirect the user to after logging out. No checking is performed on - * the URL, so make sure to verify it on beforehand if the URL is obtained from user input. Refer to - * \SimpleSAML\Utils\HTTP::checkURLAllowed() for more information. - */ - public function initLogout($returnURL) - { - assert('is_string($returnURL)'); - assert('is_string($authority)'); - - self::initLogoutReturn($returnURL); - - \SimpleSAML\Utils\HTTP::redirectTrustedURL($returnURL); - } - - - /** - * Called when logout operation completes. - * - * This function never returns. - * - * @param array $state The state after the logout. - */ - public static function logoutCompleted($state) - { - assert('is_array($state)'); - assert('array_key_exists("SimpleSAML_Auth_Default.ReturnURL", $state)'); - - \SimpleSAML\Utils\HTTP::redirectTrustedURL($state['SimpleSAML_Auth_Default.ReturnURL']); - } - - /** * Complete logout. * -- GitLab