17 $tableVer = $store->getTableVersion(
'saml_LogoutStore');
18 if ($tableVer === 2) {
20 } elseif ($tableVer === 1) {
22 $query =
'ALTER TABLE ' . $store->prefix .
'_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL';
29 $store->setTableVersion(
'saml_LogoutStore', 2);
33 $query =
'CREATE TABLE ' . $store->prefix .
'_saml_LogoutStore ( 34 _authSource VARCHAR(255) NOT NULL, 35 _nameId VARCHAR(40) NOT NULL, 36 _sessionIndex VARCHAR(50) NOT NULL, 37 _expire TIMESTAMP NOT NULL, 38 _sessionId VARCHAR(50) NOT NULL, 39 UNIQUE (_authSource, _nameID, _sessionIndex) 43 $query =
'CREATE INDEX ' . $store->prefix .
'_saml_LogoutStore_expire ON ' . $store->prefix .
'_saml_LogoutStore (_expire)';
46 $query =
'CREATE INDEX ' . $store->prefix .
'_saml_LogoutStore_nameId ON ' . $store->prefix .
'_saml_LogoutStore (_authSource, _nameId)';
49 $store->setTableVersion(
'saml_LogoutStore', 2);
62 $query =
'DELETE FROM ' . $store->prefix .
'_saml_LogoutStore WHERE _expire < :now';
79 assert(
'is_string($authId)');
80 assert(
'is_string($nameId)');
81 assert(
'is_string($sessionIndex)');
82 assert(
'is_string($sessionId)');
83 assert(
'is_int($expire)');
85 self::createLogoutTable($store);
87 if (rand(0, 1000) < 10) {
88 self::cleanLogoutStore($store);
92 '_authSource' => $authId,
95 '_expire' => gmdate(
'Y-m-d H:i:s',
$expire),
96 '_sessionId' => $sessionId,
98 $store->insertOrUpdate($store->prefix .
'_saml_LogoutStore',
array(
'_authSource',
'_nameId',
'_sessionIndex'),
$data);
111 assert(
'is_string($authId)');
112 assert(
'is_string($nameId)');
114 self::createLogoutTable($store);
117 '_authSource' => $authId,
119 'now' => gmdate(
'Y-m-d H:i:s'),
123 $query =
'SELECT _sessionIndex AS _sessionindex, _sessionId AS _sessionid FROM ' . $store->prefix .
'_saml_LogoutStore' .
124 ' WHERE _authSource = :_authSource AND _nameId = :_nameId AND _expire >= :now';
129 while ( (
$row =
$query->fetch(PDO::FETCH_ASSOC)) !== FALSE) {
130 $res[
$row[
'_sessionindex']] = $row[
'_sessionid'];
147 assert(
'is_string($authId)');
148 assert(
'is_string($nameId)');
152 $sessionId = $store->get(
'saml.LogoutStore',
$nameId .
':' . $sessionIndex);
153 if ($sessionId === NULL) {
156 assert(
'is_string($sessionId)');
178 assert(
'is_string($authId)');
179 assert(
'is_string($sessionIndex) || is_null($sessionIndex)');
180 assert(
'is_int($expire)');
202 $strNameId = serialize(
$nameId);
203 $strNameId = sha1($strNameId);
211 $sessionId =
$session->getSessionId();
229 public static function logoutSessions($authId,
$nameId,
array $sessionIndexes) {
230 assert(
'is_string($authId)');
243 $strNameId = serialize(
$nameId);
244 $strNameId = sha1($strNameId);
248 assert(
'is_string($sessionIndex)');
249 if (strlen($sessionIndex) > 50) {
250 $sessionIndex = sha1($sessionIndex);
253 unset($sessionIndex);
256 $sessions = self::getSessionsSQL(
$store, $authId, $strNameId);
257 } elseif (empty($sessionIndexes)) {
262 $sessions = self::getSessionsStore(
$store, $authId, $strNameId, $sessionIndexes);
266 if (empty($sessionIndexes)) {
267 $sessionIndexes = array_keys($sessions);
273 foreach ($sessionIndexes as $sessionIndex) {
274 if (!isset($sessions[$sessionIndex])) {
297 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.
Create styles array
The data for the language used.
static getSessionHandler()
This function retrieves the current instance of the session handler.
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.