From fb42459ce5d536572e1aa033615a329c7b6d8609 Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Mon, 31 Aug 2015 17:00:10 +0200 Subject: [PATCH] Duplicate the $state['SimpleSAML_Auth_Default.*'] entries to $state['SimpleSAML_Auth_Source.*'] where needed, while we are transitioning to 2.0. Leave those that will be removed in SimpleSAML_Auth_Default. Move the rest of the code to the new entries in the state array. --- lib/SimpleSAML/Auth/Source.php | 27 +++++++++++++++----------- modules/multiauth/www/selectsource.php | 4 ++-- modules/saml/lib/Auth/Source/SP.php | 4 ++-- modules/saml/www/sp/saml2-acs.php | 4 ++-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php index 9009fb100..b9cceb41e 100644 --- a/lib/SimpleSAML/Auth/Source.php +++ b/lib/SimpleSAML/Auth/Source.php @@ -166,18 +166,23 @@ abstract class SimpleSAML_Auth_Source assert('is_string($errorURL) || is_null($errorURL)'); $state = array_merge($params, array( - 'SimpleSAML_Auth_Default.id' => $this->authId, - 'SimpleSAML_Auth_Default.Return' => $return, - 'SimpleSAML_Auth_Default.ErrorURL' => $errorURL, + 'SimpleSAML_Auth_Default.id' => $this->authId, // TODO: remove in 2.0 + 'SimpleSAML_Auth_Source.id' => $this->authId, + 'SimpleSAML_Auth_Default.Return' => $return, // TODO: remove in 2.0 + 'SimpleSAML_Auth_Source.Return' => $return, + 'SimpleSAML_Auth_Default.ErrorURL' => $errorURL, // TODO: remove in 2.0 + 'SimpleSAML_Auth_Source.ErrorURL' => $errorURL, 'LoginCompletedHandler' => array(get_class(), 'loginCompleted'), 'LogoutCallback' => array(get_class(), 'logoutCallback'), 'LogoutCallbackState' => array( - 'SimpleSAML_Auth_Default.logoutSource' => $this->authId, + 'SimpleSAML_Auth_Default.logoutSource' => $this->authId, // TODO: remove in 2.0 + 'SimpleSAML_Auth_Source.logoutSource' => $this->authId, ), )); if (is_string($return)) { - $state['SimpleSAML_Auth_Default.ReturnURL'] = $return; + $state['SimpleSAML_Auth_Default.ReturnURL'] = $return; // TODO: remove in 2.0 + $state['SimpleSAML_Auth_Source.ReturnURL'] = $return; } if ($errorURL !== null) { @@ -206,16 +211,16 @@ abstract class SimpleSAML_Auth_Source public static function loginCompleted($state) { assert('is_array($state)'); - assert('array_key_exists("SimpleSAML_Auth_Default.Return", $state)'); - assert('array_key_exists("SimpleSAML_Auth_Default.id", $state)'); + assert('array_key_exists("SimpleSAML_Auth_Source.Return", $state)'); + assert('array_key_exists("SimpleSAML_Auth_Source.id", $state)'); assert('array_key_exists("Attributes", $state)'); assert('!array_key_exists("LogoutState", $state) || is_array($state["LogoutState"])'); - $return = $state['SimpleSAML_Auth_Default.Return']; + $return = $state['SimpleSAML_Auth_Source.Return']; // save session state $session = SimpleSAML_Session::getSessionFromRequest(); - $authId = $state['SimpleSAML_Auth_Default.id']; + $authId = $state['SimpleSAML_Auth_Source.id']; $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state)); if (is_string($return)) { // redirect... @@ -358,9 +363,9 @@ abstract class SimpleSAML_Auth_Source public static function logoutCallback($state) { assert('is_array($state)'); - assert('array_key_exists("SimpleSAML_Auth_Default.logoutSource", $state)'); + assert('array_key_exists("SimpleSAML_Auth_Source.logoutSource", $state)'); - $source = $state['SimpleSAML_Auth_Default.logoutSource']; + $source = $state['SimpleSAML_Auth_Source.logoutSource']; $session = SimpleSAML_Session::getSessionFromRequest(); if (!$session->isValid($source)) { diff --git a/modules/multiauth/www/selectsource.php b/modules/multiauth/www/selectsource.php index 8881d86ec..25119576d 100644 --- a/modules/multiauth/www/selectsource.php +++ b/modules/multiauth/www/selectsource.php @@ -17,8 +17,8 @@ if (!array_key_exists('AuthState', $_REQUEST)) { $authStateId = $_REQUEST['AuthState']; $state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_multiauth_Auth_Source_MultiAuth::STAGEID); -if (array_key_exists("SimpleSAML_Auth_Default.id", $state)) { - $authId = $state["SimpleSAML_Auth_Default.id"]; +if (array_key_exists("SimpleSAML_Auth_Source.id", $state)) { + $authId = $state["SimpleSAML_Auth_Source.id"]; $as = SimpleSAML_Auth_Source::getById($authId); } else { $as = NULL; diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index 1411b05bd..1747ffe4b 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -188,8 +188,8 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source { $ar->setAssertionConsumerServiceURL(SimpleSAML_Module::getModuleURL('saml/sp/saml2-acs.php/' . $this->authId)); - if (isset($state['SimpleSAML_Auth_Default.ReturnURL'])) { - $ar->setRelayState($state['SimpleSAML_Auth_Default.ReturnURL']); + if (isset($state['SimpleSAML_Auth_Source.ReturnURL'])) { + $ar->setRelayState($state['SimpleSAML_Auth_Source.ReturnURL']); } if (isset($state['saml:AuthnContextClassRef'])) { diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php index 624f7cca7..26e8ceb3e 100644 --- a/modules/saml/www/sp/saml2-acs.php +++ b/modules/saml/www/sp/saml2-acs.php @@ -217,8 +217,8 @@ $state['saml:sp:prevAuth'] = array( 'id' => $response->getId(), 'issuer' => $idp, ); -if (isset($state['SimpleSAML_Auth_Default.ReturnURL'])) { - $state['saml:sp:prevAuth']['redirect'] = $state['SimpleSAML_Auth_Default.ReturnURL']; +if (isset($state['SimpleSAML_Auth_Source.ReturnURL'])) { + $state['saml:sp:prevAuth']['redirect'] = $state['SimpleSAML_Auth_Source.ReturnURL']; } elseif (isset($state['saml:sp:RelayState'])) { $state['saml:sp:prevAuth']['redirect'] = $state['saml:sp:RelayState']; } -- GitLab