From 66d8bc05c46ec064166ce9f932f2cdc50309c6e4 Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Wed, 12 Aug 2015 16:07:05 +0200 Subject: [PATCH] Deprecate SimpleSAML_Default::loginCompleted() and move it to SimpleSAML_Auth_Source. --- docs/simplesamlphp-upgrade-notes-1.14.txt | 1 + lib/SimpleSAML/Auth/Default.php | 4 +-- lib/SimpleSAML/Auth/Source.php | 32 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/simplesamlphp-upgrade-notes-1.14.txt b/docs/simplesamlphp-upgrade-notes-1.14.txt index a0fcb727d..7848b07c6 100644 --- a/docs/simplesamlphp-upgrade-notes-1.14.txt +++ b/docs/simplesamlphp-upgrade-notes-1.14.txt @@ -88,6 +88,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_Auth_Default::loginCompleted()` * `SimpleSAML_Utilities` * `SimpleSAML_Utilities::addURLParameter()` * `SimpleSAML_Utilities::aesDecrypt()` diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php index ca28cb2f1..605825dab 100644 --- a/lib/SimpleSAML/Auth/Default.php +++ b/lib/SimpleSAML/Auth/Default.php @@ -87,9 +87,7 @@ class SimpleSAML_Auth_Default { /** - * Called when a login operation has finished. - * - * @param array $state The state after the login. + * @deprecated This method will be removed in SSP 2.0. */ public static function loginCompleted($state) { assert('is_array($state)'); diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php index 4f071fa71..9f45a607e 100644 --- a/lib/SimpleSAML/Auth/Source.php +++ b/lib/SimpleSAML/Auth/Source.php @@ -147,6 +147,38 @@ abstract class SimpleSAML_Auth_Source } + /** + * Called when a login operation has finished. + * + * This method never returns. + * + * @param array $state The state after the login has completed. + */ + protected 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("Attributes", $state)'); + assert('!array_key_exists("LogoutState", $state) || is_array($state["LogoutState"])'); + + $return = $state['SimpleSAML_Auth_Default.Return']; + + // save session state + $session = SimpleSAML_Session::getSessionFromRequest(); + $authId = $state['SimpleSAML_Auth_Default.id']; + $state = SimpleSAML_Auth_State::extractPersistentAuthState($state); + $session->doLogin($authId, $state); + + if (is_string($return)) { // redirect... + \SimpleSAML\Utils\HTTP::redirectTrustedURL($return); + } else { + call_user_func($return, $state); + } + assert('false'); + } + + /** * Log out from this authentication source. * -- GitLab