From d89759f4c258ee854ba8b9c111a6b34034aaea04 Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Wed, 12 Aug 2015 15:26:13 +0200 Subject: [PATCH] Move SimpleSAML_Auth_Default::handleUnsolicitedAuth() to sspmod_saml_Auth_Source_SP::handleUnsolicitedAuth() and deprecate the former. --- docs/simplesamlphp-upgrade-notes-1.14.txt | 1 + lib/SimpleSAML/Auth/Default.php | 30 +++-------------------- modules/saml/lib/Auth/Source/SP.php | 25 ++++++++++++++++++- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/simplesamlphp-upgrade-notes-1.14.txt b/docs/simplesamlphp-upgrade-notes-1.14.txt index 9dbadd813..a0fcb727d 100644 --- a/docs/simplesamlphp-upgrade-notes-1.14.txt +++ b/docs/simplesamlphp-upgrade-notes-1.14.txt @@ -87,6 +87,7 @@ The following methods and classes have been deprecated. Refer to the code for al * `SimpleSAML_Auth_Default` * `SimpleSAML_Auth_Default::extractPersistentAuthState()` + * `SimpleSAML_Auth_Default::handleUnsolicitedAuth()` * `SimpleSAML_Utilities` * `SimpleSAML_Utilities::addURLParameter()` * `SimpleSAML_Utilities::aesDecrypt()` diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php index b50e778f8..ca28cb2f1 100644 --- a/lib/SimpleSAML/Auth/Default.php +++ b/lib/SimpleSAML/Auth/Default.php @@ -76,11 +76,6 @@ class SimpleSAML_Auth_Default { /** - * Extract the persistent authentication state from the state array. - * - * @param array $state The state after the login. - * @return array The persistent authentication state. - * * @deprecated This method will be removed in SSP 2.0. Please use * SimpleSAML_Auth_State::extractPersistentAuthState() instead. */ @@ -227,30 +222,11 @@ class SimpleSAML_Auth_Default { /** - * Handle a unsolicited login operations. - * - * This function creates a session from the received information. It - * will then redirect to the given URL. - * - * This is used to handle IdP initiated SSO. - * - * @param string $authId The id of the authentication source that received - * the request. - * @param array $state A state array. - * @param string $redirectTo The URL we should redirect the user to after - * updating the session. The function will check if the URL is allowed, so - * there is no need to manually check the URL on beforehand. Please refer - * to the 'trusted.url.domains' configuration directive for more - * information about allowing (or disallowing) URLs. + * @deprecated This method will be removed in SSP 2.0. Please use + * sspmod_saml_Auth_Source_SP::handleUnsolicitedAuth() instead. */ public static function handleUnsolicitedAuth($authId, array $state, $redirectTo) { - assert('is_string($authId)'); - assert('is_string($redirectTo)'); - - $session = SimpleSAML_Session::getSessionFromRequest(); - $session->doLogin($authId, SimpleSAML_Auth_State::extractPersistentAuthState($state)); - - \SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo); + sspmod_saml_Auth_Source_SP::handleUnsolicitedAuth($authId, $state, $redirectTo); } } diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index 569f2b5c6..cb926f628 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -579,6 +579,29 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source { } + /** + * Handle an unsolicited login operations. + * + * This method creates a session from the information received. It will then redirect to the given URL. This is used + * to handle IdP initiated SSO. This method will never return. + * + * @param string $authId The id of the authentication source that received the request. + * @param array $state A state array. + * @param string $redirectTo The URL we should redirect the user to after updating the session. The function will + * check if the URL is allowed, so there is no need to manually check the URL on beforehand. Please refer to the + * 'trusted.url.domains' configuration directive for more information about allowing (or disallowing) URLs. + */ + public static function handleUnsolicitedAuth($authId, array $state, $redirectTo) { + assert('is_string($authId)'); + assert('is_string($redirectTo)'); + + $session = SimpleSAML_Session::getSessionFromRequest(); + $session->doLogin($authId, SimpleSAML_Auth_State::extractPersistentAuthState($state)); + + \SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo); + } + + /** * Called when we have completed the procssing chain. * @@ -609,7 +632,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source { } else { $redirectTo = $source->getMetadata()->getString('RelayState', '/'); } - SimpleSAML_Auth_Default::handleUnsolicitedAuth($sourceId, $state, $redirectTo); + self::handleUnsolicitedAuth($sourceId, $state, $redirectTo); } SimpleSAML_Auth_Source::completeAuth($state); -- GitLab