From fd06434b89a16525577c7b7049b03dc7a7dda0ea Mon Sep 17 00:00:00 2001 From: Peter Jaap Blaakmeer Date: Thu, 9 Jun 2022 16:53:15 +0200 Subject: [PATCH 1/2] PHP 8.1 compatibility Remove mcrypt references completely - it has been removed in PHP 7.2. This is the only blocker for PHP 8.1 compatibility; ``` vendor/bin/phpcs -p vendor/juashyam/authenticator --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --runtime-set testVersion 8.1 ........E. 10 / 10 (100%) FILE: ...or/juashyam/authenticator/Lib/PHPGangsta/GoogleAuthenticator.php ---------------------------------------------------------------------- FOUND 3 ERRORS AFFECTING 1 LINE ---------------------------------------------------------------------- 38 | ERROR | Function mcrypt_create_iv() is deprecated since PHP 7.1 | | and removed since PHP 7.2; Use random_bytes() or | | OpenSSL instead 38 | ERROR | Extension 'mcrypt' is deprecated since PHP 7.1 and | | removed since PHP 7.2; Use openssl (preferred) or | | pecl/mcrypt once available instead 38 | ERROR | The constant "MCRYPT_DEV_URANDOM" is deprecated since | | PHP 7.1 and removed since PHP 7.2 ---------------------------------------------------------------------- Time: 275ms; Memory: 12MB ``` --- Lib/PHPGangsta/GoogleAuthenticator.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/PHPGangsta/GoogleAuthenticator.php b/Lib/PHPGangsta/GoogleAuthenticator.php index 4870c35..b4b9829 100644 --- a/Lib/PHPGangsta/GoogleAuthenticator.php +++ b/Lib/PHPGangsta/GoogleAuthenticator.php @@ -34,8 +34,6 @@ public function createSecret($secretLength = 16) $rnd = false; if (function_exists('random_bytes')) { $rnd = random_bytes($secretLength); - } elseif (function_exists('mcrypt_create_iv')) { - $rnd = mcrypt_create_iv($secretLength, MCRYPT_DEV_URANDOM); } elseif (function_exists('openssl_random_pseudo_bytes')) { $rnd = openssl_random_pseudo_bytes($secretLength, $cryptoStrong); if (!$cryptoStrong) { @@ -250,4 +248,4 @@ private function timingSafeEquals($safeString, $userString) // They are only identical strings if $result is exactly 0... return $result === 0; } -} \ No newline at end of file +} From 7d7482fc2b9e3179f39a80687cbecb6401f20937 Mon Sep 17 00:00:00 2001 From: Peter Jaap Blaakmeer Date: Thu, 9 Jun 2022 16:53:58 +0200 Subject: [PATCH 2/2] Loosened PHP version constraints for PHP 7.4 and PHP 8.x --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d4eafb7..3413c81 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "juashyam/authenticator", "description": "Magento 2 Backend 2FA implementation", "require": { - "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0", + "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.0.0|~8.1.0", "magento/framework": "^100.1.0|101.0.*|^102.0.0" }, "type": "magento2-module", @@ -18,4 +18,4 @@ "Neyamtux\\Authenticator\\": "" } } -} \ No newline at end of file +}