17 $tableVer = $store->getTableVersion(
'saml_LogoutStore');
18 if ($tableVer === 2) {
20 } elseif ($tableVer === 1) {
22 switch ($store->driver) {
25 $query =
'ALTER TABLE ' . $store->prefix .
'_saml_LogoutStore ALTER COLUMN _authSource TYPE VARCHAR(255)';
28 $query =
'ALTER TABLE ' . $store->prefix .
'_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL';
38 $store->setTableVersion(
'saml_LogoutStore', 2);
42 $query =
'CREATE TABLE ' . $store->prefix .
'_saml_LogoutStore ( 43 _authSource VARCHAR(255) NOT NULL, 44 _nameId VARCHAR(40) NOT NULL, 45 _sessionIndex VARCHAR(50) NOT NULL, 46 _expire TIMESTAMP NOT NULL, 47 _sessionId VARCHAR(50) NOT NULL, 48 UNIQUE (_authSource, _nameID, _sessionIndex) 52 $query =
'CREATE INDEX ' . $store->prefix .
'_saml_LogoutStore_expire ON ' . $store->prefix .
'_saml_LogoutStore (_expire)';
55 $query =
'CREATE INDEX ' . $store->prefix .
'_saml_LogoutStore_nameId ON ' . $store->prefix .
'_saml_LogoutStore (_authSource, _nameId)';
58 $store->setTableVersion(
'saml_LogoutStore', 2);
71 $query =
'DELETE FROM ' . $store->prefix .
'_saml_LogoutStore WHERE _expire < :now';
72 $params = array(
'now' => gmdate(
'Y-m-d H:i:s'));
89 assert(is_string($authId));
92 assert(is_string($sessionId));
95 self::createLogoutTable($store);
97 if (rand(0, 1000) < 10) {
98 self::cleanLogoutStore($store);
102 '_authSource' => $authId,
105 '_expire' => gmdate(
'Y-m-d H:i:s',
$expire),
106 '_sessionId' => $sessionId,
108 $store->insertOrUpdate($store->prefix .
'_saml_LogoutStore', array(
'_authSource',
'_nameId',
'_sessionIndex'),
$data);
122 assert(is_string($authId));
125 self::createLogoutTable($store);
128 '_authSource' => $authId,
130 'now' => gmdate(
'Y-m-d H:i:s'),
134 $query =
'SELECT _sessionIndex AS _sessionindex, _sessionId AS _sessionid FROM ' . $store->prefix .
'_saml_LogoutStore' .
135 ' WHERE _authSource = :_authSource AND _nameId = :_nameId AND _expire >= :now';
140 while ( (
$row =
$query->fetch(PDO::FETCH_ASSOC)) !==
false) {
141 $res[
$row[
'_sessionindex']] = $row[
'_sessionid'];
159 assert(is_string($authId));
164 $sessionId = $store->get(
'saml.LogoutStore',
$nameId .
':' . $sessionIndex);
165 if ($sessionId === null) {
168 assert(is_string($sessionId));
191 assert(is_string($authId));
215 $strNameId = serialize(
$nameId);
216 $strNameId = sha1($strNameId);
224 $sessionId =
$session->getSessionId();
242 public static function logoutSessions($authId,
$nameId, array $sessionIndexes)
244 assert(is_string($authId));
257 $strNameId = serialize(
$nameId);
258 $strNameId = sha1($strNameId);
262 assert(is_string($sessionIndex));
263 if (strlen($sessionIndex) > 50) {
264 $sessionIndex = sha1($sessionIndex);
267 unset($sessionIndex);
270 $sessions = self::getSessionsSQL(
$store, $authId, $strNameId);
271 } elseif (empty($sessionIndexes)) {
276 $sessions = self::getSessionsStore(
$store, $authId, $strNameId, $sessionIndexes);
280 if (empty($sessionIndexes)) {
281 $sessionIndexes = array_keys($sessions);
285 foreach ($sessionIndexes as $sessionIndex) {
286 if (!isset($sessions[$sessionIndex])) {
309 return $numLoggedOut;
static generateID()
Generate a random identifier, ID_LENGTH bytes long.
static addSession($authId, $nameId, $sessionIndex, $expire)
Register a new session in the datastore.
static getSessionsStore(\SimpleSAML\Store $store, $authId, $nameId, array $sessionIndexes)
Retrieve all session IDs from a key-value store.
static cleanLogoutStore(\SimpleSAML\Store\SQL $store)
Clean the logout table of expired entries.
static getSessionsSQL(\SimpleSAML\Store\SQL $store, $authId, $nameId)
Retrieve sessions from the SQL datastore.
static getSession($sessionId=null)
Get a session from the session handler.
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Attribute-related utility methods.
foreach($_POST as $key=> $value) $res
static addSessionSQL(\SimpleSAML\Store\SQL $store, $authId, $nameId, $sessionIndex, $expire, $sessionId)
Register a session in the SQL datastore.
static getInstance()
Retrieve our singleton instance.
static getSessionFromRequest()
Retrieves the current session.
static createLogoutTable(\SimpleSAML\Store\SQL $store)
Create logout table in SQL, if it is missing.
static fromArray(array $nameId)
Create a object from an array with its contents.