Skip to content
Snippets Groups Projects
Commit 77f61d58 authored by Olav Morken's avatar Olav Morken
Browse files

Auth/Source: Add logout state to authentication sources.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@978 44740490-163a-0410-bde0-09ae8108e29a
parent 56c6bb7f
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,7 @@ class SimpleSAML_Auth_Default { ...@@ -66,6 +66,7 @@ class SimpleSAML_Auth_Default {
assert('array_key_exists("SimpleSAML_Auth_Default.ReturnURL", $state)'); assert('array_key_exists("SimpleSAML_Auth_Default.ReturnURL", $state)');
assert('array_key_exists("SimpleSAML_Auth_Default.id", $state)'); assert('array_key_exists("SimpleSAML_Auth_Default.id", $state)');
assert('array_key_exists("Attributes", $state)'); assert('array_key_exists("Attributes", $state)');
assert('!array_key_exists("LogoutState", $state) || is_array($state["LogoutState"])');
$returnURL = $state['SimpleSAML_Auth_Default.ReturnURL']; $returnURL = $state['SimpleSAML_Auth_Default.ReturnURL'];
...@@ -77,6 +78,10 @@ class SimpleSAML_Auth_Default { ...@@ -77,6 +78,10 @@ class SimpleSAML_Auth_Default {
$session->setSessionDuration($state['Expires'] - time()); $session->setSessionDuration($state['Expires'] - time());
} }
if (array_key_exists('LogoutState', $state)) {
$session->setLogoutState($state['LogoutState']);
}
/* Redirect... */ /* Redirect... */
SimpleSAML_Utilities::redirect($returnURL); SimpleSAML_Utilities::redirect($returnURL);
} }
...@@ -121,15 +126,15 @@ class SimpleSAML_Auth_Default { ...@@ -121,15 +126,15 @@ class SimpleSAML_Auth_Default {
public static function initLogout($returnURL) { public static function initLogout($returnURL) {
assert('is_string($returnURL)'); assert('is_string($returnURL)');
$state = array(
'SimpleSAML_Auth_Default.ReturnURL' => $returnURL,
'LogoutCompletedHandler' => array(get_class(), 'logoutCompleted'),
);
$session = SimpleSAML_Session::getInstance(); $session = SimpleSAML_Session::getInstance();
$state = $session->getLogoutState();
$authId = $session->getAuthority(); $authId = $session->getAuthority();
$session->doLogout(); $session->doLogout();
$state['SimpleSAML_Auth_Default.ReturnURL'] = $returnURL;
$state['LogoutCompletedHandler'] = array(get_class(), 'logoutCompleted');
$as = SimpleSAML_Auth_Source::getById($authId); $as = SimpleSAML_Auth_Source::getById($authId);
if ($as === NULL) { if ($as === NULL) {
/* The authority wasn't an authentication source... */ /* The authority wasn't an authentication source... */
......
...@@ -76,6 +76,12 @@ class SimpleSAML_Session { ...@@ -76,6 +76,12 @@ class SimpleSAML_Session {
private $sessionNameId; private $sessionNameId;
/**
* Logout state when authenticated with authentication sources.
*/
private $logoutState;
/** /**
* private constructor restricts instantiaton to getInstance() * private constructor restricts instantiaton to getInstance()
*/ */
...@@ -405,6 +411,7 @@ class SimpleSAML_Session { ...@@ -405,6 +411,7 @@ class SimpleSAML_Session {
$this->authenticated = FALSE; $this->authenticated = FALSE;
$this->authority = NULL; $this->authority = NULL;
$this->attributes = NULL; $this->attributes = NULL;
$this->logoutState = NULL;
} }
...@@ -816,6 +823,34 @@ class SimpleSAML_Session { ...@@ -816,6 +823,34 @@ class SimpleSAML_Session {
register_shutdown_function(array($this, 'saveSession')); 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment