From 7c73e2cf748a969ae6bb6d956dc6a470e6fd2d58 Mon Sep 17 00:00:00 2001 From: Dmitry Dulepov Date: Tue, 19 Nov 2019 11:49:37 +0200 Subject: [PATCH 1/7] [TASK] #27: add support for TYPO3 v10 --- composer.json | 4 ++-- ext_emconf.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 85a424a..ff0b2fa 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,8 @@ "ext-gmp": "*", "ext-curl": "*", "ext-dom": "*", - "typo3/cms-core": ">=8.7.19,<=9.5.999", - "typo3/cms-setup": ">=8.7.19,<=9.5.999" + "typo3/cms-core": ">=10.0.0,<=10.999.999", + "typo3/cms-setup": ">=10.0.0,<=10.999.999" }, "replace": { "openid": "self.version", diff --git a/ext_emconf.php b/ext_emconf.php index daf2cd7..d230d33 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,11 +8,11 @@ 'uploadfolder' => false, 'createDirs' => '', 'clearCacheOnLoad' => false, - 'version' => '8.1.1', + 'version' => '10.0.0', 'constraints' => [ 'depends' => [ - 'typo3' => '8.7.19-9.5.999', - 'setup' => '8.7.19-9.5.999', + 'typo3' => '10.0.0-10.999.999', + 'setup' => '10.0.0-10.999.999', ], 'conflicts' => [ 'naw_openid' => '', From eebc22bb62b04b8e5cd8f393317f26fdc1d5a482 Mon Sep 17 00:00:00 2001 From: Dmitry Dulepov Date: Tue, 19 Nov 2019 12:47:41 +0200 Subject: [PATCH 2/7] [BUGFIX] #27: valid endpoint is not returned (see https://github.com/openid/php-openid/pull/140) --- lib/php-openid/Auth/OpenID/Consumer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/php-openid/Auth/OpenID/Consumer.php b/lib/php-openid/Auth/OpenID/Consumer.php index 476f9c1..a22adfd 100644 --- a/lib/php-openid/Auth/OpenID/Consumer.php +++ b/lib/php-openid/Auth/OpenID/Consumer.php @@ -1263,7 +1263,7 @@ function _verifyDiscoveryServices($claimed_id, foreach ($to_match_endpoints as $to_match_endpoint) { $result = $this->_verifyDiscoverySingle($endpoint, $to_match_endpoint); - if ($result && !Auth_OpenID::isFailure($result)) { + if (!Auth_OpenID::isFailure($result)) { // It matches, so discover verification has // succeeded. Return this endpoint. return $endpoint; From acab998a772ceda156f6769d3db73e412ce523d8 Mon Sep 17 00:00:00 2001 From: Dmitry Dulepov Date: Tue, 19 Nov 2019 13:18:00 +0200 Subject: [PATCH 3/7] [TASK] #27: replace functionaly removed in TYPO3 v10 with new one --- Classes/OpenidService.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Classes/OpenidService.php b/Classes/OpenidService.php index a155028..5b97bf8 100644 --- a/Classes/OpenidService.php +++ b/Classes/OpenidService.php @@ -14,10 +14,12 @@ * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Crypto\Random; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; +use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Service\AbstractService; use TYPO3\CMS\Core\TimeTracker\TimeTracker; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; @@ -76,6 +78,9 @@ class OpenidService extends AbstractService */ protected static $openIDLibrariesIncluded = false; + /** @var \Psr\Log\LoggerInterface */ + protected $logger; + /** * Checks if service is available,. In case of this service we check that * prerequisites for "PHP OpenID" libraries are fulfilled: @@ -86,6 +91,8 @@ class OpenidService extends AbstractService */ public function init() { + $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); + $available = false; if (extension_loaded('gmp')) { $available = is_callable('gmp_init'); @@ -244,7 +251,7 @@ protected function includePHPOpenIDLibrary() // Make sure that random generator is properly set up. Constant could be // defined by the previous inclusion of the file if (!defined('Auth_OpenID_RAND_SOURCE')) { - if (TYPO3_OS === 'WIN') { + if (Environment::isWindows()) { // No random generator on Windows! define('Auth_OpenID_RAND_SOURCE', null); } elseif (!is_readable('/dev/urandom')) { @@ -584,11 +591,7 @@ protected function writeLog($message) array_shift($params); $message = vsprintf($message, $params); } - if (TYPO3_MODE === 'BE') { - GeneralUtility::sysLog($message, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_NOTICE); - } - if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']) { - GeneralUtility::devLog($message, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_NOTICE); - } + + $this->logger->notice($message); } } From 084be401067d676e6c44307b964b747f0a755d2b Mon Sep 17 00:00:00 2001 From: Dmitry Dulepov Date: Tue, 19 Nov 2019 13:18:55 +0200 Subject: [PATCH 4/7] [TASK] #27: in TYPO3 v10 this service has to be singleton because it is instantiated multiple times, which causes multiple requests and nonce uniqueness failure --- Classes/OpenidService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/OpenidService.php b/Classes/OpenidService.php index 5b97bf8..cc929cd 100644 --- a/Classes/OpenidService.php +++ b/Classes/OpenidService.php @@ -21,7 +21,7 @@ use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Service\AbstractService; -use TYPO3\CMS\Core\TimeTracker\TimeTracker; +use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Authentication\AbstractUserAuthentication; @@ -32,7 +32,7 @@ /** * Service "OpenID Authentication" for the "openid" extension. */ -class OpenidService extends AbstractService +class OpenidService extends AbstractService implements SingletonInterface { /** * The extension key From 669c8eff365299143b75ef98762fb25c0fa577a2 Mon Sep 17 00:00:00 2001 From: Dmitry Dulepov Date: Thu, 21 Nov 2019 15:58:48 +0200 Subject: [PATCH 5/7] [TASK] #27: document php-openid extra fix in README --- lib/php-openid/README.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/php-openid/README.txt b/lib/php-openid/README.txt index c102b02..1be38e3 100644 --- a/lib/php-openid/README.txt +++ b/lib/php-openid/README.txt @@ -4,3 +4,6 @@ We use only "Auth" directory from the library and include a copy of COPYING file Current version of the library is 2.3.0 (git-checkout 3847f38; # from 2017-04-14) Source: https://github.com/openid/php-openid + +Additionally copied the following bugfix to this version: https://github.com/openid/php-openid/pull/140 + From b5470b85e9385e70fcbd7a5507e845cd8bd3e20e Mon Sep 17 00:00:00 2001 From: Dmitry Dulepov Date: Thu, 21 Nov 2019 16:03:56 +0200 Subject: [PATCH 6/7] [TASK] #27: use Psr logger interface & trait --- Classes/OpenidService.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Classes/OpenidService.php b/Classes/OpenidService.php index cc929cd..d8cd4c3 100644 --- a/Classes/OpenidService.php +++ b/Classes/OpenidService.php @@ -14,6 +14,8 @@ * The TYPO3 project - inspiring people to share! */ +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Crypto\Random; use TYPO3\CMS\Core\Database\Connection; @@ -32,8 +34,10 @@ /** * Service "OpenID Authentication" for the "openid" extension. */ -class OpenidService extends AbstractService implements SingletonInterface +class OpenidService extends AbstractService implements SingletonInterface, LoggerAwareInterface { + use LoggerAwareTrait; + /** * The extension key * @@ -78,9 +82,6 @@ class OpenidService extends AbstractService implements SingletonInterface */ protected static $openIDLibrariesIncluded = false; - /** @var \Psr\Log\LoggerInterface */ - protected $logger; - /** * Checks if service is available,. In case of this service we check that * prerequisites for "PHP OpenID" libraries are fulfilled: @@ -91,7 +92,7 @@ class OpenidService extends AbstractService implements SingletonInterface */ public function init() { - $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); + $this->setLogger(GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__)); $available = false; if (extension_loaded('gmp')) { From 1a1def2647fb166715e2710864fc83866e0cb6fa Mon Sep 17 00:00:00 2001 From: Dmitry Dulepov Date: Thu, 21 Nov 2019 18:11:18 +0200 Subject: [PATCH 7/7] [TASK] #27: remove database creation options that cause failures with TYPO3 v10 sql parser --- ext_tables.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext_tables.sql b/ext_tables.sql index 1b6d915..2b2e928 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -44,4 +44,4 @@ CREATE TABLE tx_openid_nonce_store ( PRIMARY KEY (uid), UNIQUE KEY nonce (server_url(255),tstamp,salt), KEY crdate (crdate) -) DEFAULT CHARSET = utf8 COLLATE utf8_general_ci ENGINE=InnoDB; +) ENGINE=InnoDB;