From 77f61d58e965221bc5e22738c18be4ecfc22f2fa Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 10 Nov 2008 12:59:46 +0000 Subject: [PATCH] Auth/Source: Add logout state to authentication sources. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@978 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Auth/Default.php | 15 +++++++++----- lib/SimpleSAML/Session.php | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php index 33b20cb84..5f620a341 100644 --- a/lib/SimpleSAML/Auth/Default.php +++ b/lib/SimpleSAML/Auth/Default.php @@ -66,6 +66,7 @@ class SimpleSAML_Auth_Default { assert('array_key_exists("SimpleSAML_Auth_Default.ReturnURL", $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"])'); $returnURL = $state['SimpleSAML_Auth_Default.ReturnURL']; @@ -77,6 +78,10 @@ class SimpleSAML_Auth_Default { $session->setSessionDuration($state['Expires'] - time()); } + if (array_key_exists('LogoutState', $state)) { + $session->setLogoutState($state['LogoutState']); + } + /* Redirect... */ SimpleSAML_Utilities::redirect($returnURL); } @@ -121,15 +126,15 @@ class SimpleSAML_Auth_Default { public static function initLogout($returnURL) { assert('is_string($returnURL)'); - $state = array( - 'SimpleSAML_Auth_Default.ReturnURL' => $returnURL, - 'LogoutCompletedHandler' => array(get_class(), 'logoutCompleted'), - ); - $session = SimpleSAML_Session::getInstance(); + + $state = $session->getLogoutState(); $authId = $session->getAuthority(); $session->doLogout(); + $state['SimpleSAML_Auth_Default.ReturnURL'] = $returnURL; + $state['LogoutCompletedHandler'] = array(get_class(), 'logoutCompleted'); + $as = SimpleSAML_Auth_Source::getById($authId); if ($as === NULL) { /* The authority wasn't an authentication source... */ diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 19a18b362..4dc3ef24e 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -76,6 +76,12 @@ class SimpleSAML_Session { private $sessionNameId; + /** + * Logout state when authenticated with authentication sources. + */ + private $logoutState; + + /** * private constructor restricts instantiaton to getInstance() */ @@ -405,6 +411,7 @@ class SimpleSAML_Session { $this->authenticated = FALSE; $this->authority = NULL; $this->attributes = NULL; + $this->logoutState = NULL; } @@ -816,6 +823,34 @@ class SimpleSAML_Session { register_shutdown_function(array($this, 'saveSession')); } + + /** + * Set the logout state for this session. + * + * @param array $state The state array. + */ + public function setLogoutState($state) { + assert('is_array($state)'); + + $this->dirty = TRUE; + $this->logoutState = $state; + } + + + /** + * Retrieve the logout state for this session. + * + * @return array The logout state. If no logout state is set, an empty array will be returned. + */ + public function getLogoutState() { + + if ($this->logoutState === NULL) { + return array(); + } + + return $this->logoutState; + } + } ?> \ No newline at end of file -- GitLab