From 1681c295210b1966462a90b0606288b83882e9c1 Mon Sep 17 00:00:00 2001 From: Romanos Dodopoulos <romanos.dodopoulos@cern.ch> Date: Sun, 16 Apr 2017 20:46:34 +0200 Subject: [PATCH] Increase the _authSource VARCHAR size to 255 The _authSource column stores FQDNs. Increase the VARCHAR size from 30 to 255 since this is the maximum allowed length of a FQDN (RFC1035). Also, increase the TableVersion to 2 and MODIFY the column size of existing version 1 tables. Fixes #579 --- modules/saml/lib/SP/LogoutStore.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php index 346db25bc..f04447b31 100644 --- a/modules/saml/lib/SP/LogoutStore.php +++ b/modules/saml/lib/SP/LogoutStore.php @@ -14,12 +14,24 @@ class sspmod_saml_SP_LogoutStore { */ private static function createLogoutTable(\SimpleSAML\Store\SQL $store) { - if ($store->getTableVersion('saml_LogoutStore') === 1) { + $tableVer = $store->getTableVersion('saml_LogoutStore'); + if ($tableVer === 2) { + return; + } elseif ($tableVer === 1) { + /* TableVersion 2 increased the column size to 255 which is the maximum length of a FQDN. */ + $query = 'ALTER TABLE ' . $store->prefix . '_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL'; + try { + $ret = $store->pdo->exec($query); + } catch (Exception $e) { + SimpleSAML\Logger::warning($store->pdo->errorInfo()); + return; + } + $store->setTableVersion('saml_LogoutStore', 2); return; } $query = 'CREATE TABLE ' . $store->prefix . '_saml_LogoutStore ( - _authSource VARCHAR(30) NOT NULL, + _authSource VARCHAR(255) NOT NULL, _nameId VARCHAR(40) NOT NULL, _sessionIndex VARCHAR(50) NOT NULL, _expire TIMESTAMP NOT NULL, @@ -34,7 +46,7 @@ class sspmod_saml_SP_LogoutStore { $query = 'CREATE INDEX ' . $store->prefix . '_saml_LogoutStore_nameId ON ' . $store->prefix . '_saml_LogoutStore (_authSource, _nameId)'; $store->pdo->exec($query); - $store->setTableVersion('saml_LogoutStore', 1); + $store->setTableVersion('saml_LogoutStore', 2); } -- GitLab