From f12b6d21edea44245aec7db0f2c1f4c6aecbefce Mon Sep 17 00:00:00 2001 From: Shaker Hasan Date: Mon, 28 Feb 2022 08:38:38 +0100 Subject: [PATCH 1/3] [TASK] Supported TYPO3-10 --- .../Controller/Frontend/SetupController.php | 4 +- Classes/Hook/FeLogin.php | 2 +- Classes/Hook/TCEMain.php | 7 + Classes/Hook/UserSettings.php | 36 +-- Classes/Hook/UserSettingsProfile.php | 227 ++++++++++++++++++ Configuration/Extbase/Persistence/Classes.php | 10 + Configuration/TCA/Overrides/be_users.php | 2 +- Configuration/TCA/Overrides/fe_users.php | 2 +- .../FrontendLogin/Email/PasswordRecovery.html | 11 + .../FrontendLogin.html | 0 .../Templates/FrontendLogin/Login/Login.html | 92 +++++++ .../Templates/FrontendLogin/Login/Logout.html | 23 ++ .../PasswordRecovery/Recovery.html | 21 ++ .../PasswordRecovery/ShowChangePassword.html | 30 +++ .../Public/Icons/Extension.png | Bin composer.json | 15 +- ext_conf_template.txt | 4 +- ext_emconf.php | 67 +++--- ext_localconf.php | 37 +-- ext_tables.php | 61 +++-- 20 files changed, 531 insertions(+), 120 deletions(-) create mode 100644 Classes/Hook/UserSettingsProfile.php create mode 100644 Configuration/Extbase/Persistence/Classes.php create mode 100644 Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html rename Resources/Private/Templates/{FeLogin => FrontendLogin}/FrontendLogin.html (100%) create mode 100644 Resources/Private/Templates/FrontendLogin/Login/Login.html create mode 100644 Resources/Private/Templates/FrontendLogin/Login/Logout.html create mode 100644 Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html create mode 100644 Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html rename ext_icon.png => Resources/Public/Icons/Extension.png (100%) diff --git a/Classes/Controller/Frontend/SetupController.php b/Classes/Controller/Frontend/SetupController.php index 7cbc2a4..f3ef61c 100644 --- a/Classes/Controller/Frontend/SetupController.php +++ b/Classes/Controller/Frontend/SetupController.php @@ -33,7 +33,7 @@ use TYPO3\CMS\Extbase\Object\Exception as ObjectException; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; -use TYPO3\CMS\Lang\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageService; use function get_class; use function vsprintf; @@ -93,7 +93,7 @@ public function __construct( Context $context ) { - parent::__construct(); + //parent::__construct(); $this->frontendUserRepository = $frontendUserRepository; $this->qrCodeGenerator = $qrCodeGenerator; diff --git a/Classes/Hook/FeLogin.php b/Classes/Hook/FeLogin.php index 85c6b6d..404df00 100644 --- a/Classes/Hook/FeLogin.php +++ b/Classes/Hook/FeLogin.php @@ -18,7 +18,7 @@ use CodeFareith\CfGoogleAuthenticator\Utility\ExtensionBasicDataUtility; use CodeFareith\CfGoogleAuthenticator\Utility\PathUtility; use TYPO3\CMS\Core\Service\MarkerBasedTemplateService; -use TYPO3\CMS\Lang\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageService; /** * Hook for the TYPO3 CMS extension 'felogin' diff --git a/Classes/Hook/TCEMain.php b/Classes/Hook/TCEMain.php index 455c89e..ebbb449 100644 --- a/Classes/Hook/TCEMain.php +++ b/Classes/Hook/TCEMain.php @@ -75,6 +75,13 @@ public function processDatamap_preProcessFieldArray( $otpInFieldArray = $otpInPostData; } + $otpInFieldArray2 = &$fieldArray['tx_cfgoogleauthenticator_secret']; + $otpInPostData2 = $_POST['data']['be_users']['tx_cfgoogleauthenticator_secret']; + + if ($otpInFieldArray2 === null && $otpInPostData2 !== null) { + $otpInFieldArray2 = $otpInPostData2; + } + $preProcessFieldArrayDTO = $this->getPreProcessFieldArrayDTO($fieldArray, $table, (int) $id, $dataHandler); $result = $this->getGoogleAuthenticatorSetupHandler()->process($preProcessFieldArrayDTO); diff --git a/Classes/Hook/UserSettings.php b/Classes/Hook/UserSettings.php index 7729060..c544c98 100644 --- a/Classes/Hook/UserSettings.php +++ b/Classes/Hook/UserSettings.php @@ -26,6 +26,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView; use function sprintf; use function vsprintf; +use TYPO3\CMS\Backend\Form\Element\AbstractFormElement; /** * Hook for the user settings @@ -37,7 +38,7 @@ * @package CodeFareith\CfGoogleAuthenticator\Hook * @since 1.0.0 */ -class UserSettings +class UserSettings extends AbstractFormElement { /*─────────────────────────────────────────────────────────────────────────────*\ Traits @@ -71,21 +72,20 @@ class UserSettings * @return string * @throws Exception */ - public function createSecretField(array $data): string + public function render(): array { - $this->data = $data; - + $result = $this->initializeResultArray(); $authenticationSecret = $this->getAuthenticationSecret(); $templateView = $this->initializeTemplateView(); $isEnabled = $this->isGoogleAuthenticatorEnabled(); $qrCodeUri = $this->getQrCodeGenerator()->generateUri($authenticationSecret); $prefix = ''; - if ($data['table'] !== null) { - $prefix .= sprintf('[%s]', $data['table']); + if ($this->data['tableName'] !== null) { + $prefix .= sprintf('[%s]', $this->data['tableName']); } - if ($data['row']['uid'] !== null) { - $prefix .= sprintf('[%s]', (string)$data['row']['uid']); + if ($data['databaseRow']['uid'] !== null) { + $prefix .= sprintf('[%s]', (string)$this->data['databaseRow']['uid']); } $templateView->assignMultiple( @@ -97,7 +97,9 @@ public function createSecretField(array $data): string ] ); - return $templateView->render(); + $result['html'] = $templateView->render(); + + return $result; } private function initializeTemplateView(): StandaloneView @@ -146,15 +148,15 @@ private function getLayer(): string { $layer = ''; - if ($this->data['table'] === 'fe_users') { + if ($this->data['tableName'] === 'fe_users') { $layer = 'Frontend'; - } elseif ($this->data['table'] === 'be_users') { + } elseif ($this->data['tableName'] === 'be_users') { $layer = 'Backend'; } $dispatcher = GeneralUtility::makeInstance(Dispatcher::class); $signalArguments = [ - 'table' => $this->data['table'], + 'table' => $this->data['tableName'], 'layer' => $layer, 'caller' => $this, ]; @@ -169,7 +171,7 @@ private function getLayer(): string private function getUsername(): string { - return $this->data['row']['username'] ?? ''; + return $this->data['databaseRow']['username'] ?? ''; } /** @@ -195,7 +197,7 @@ private function getAuthenticationSecret(): AuthenticationSecret private function getSecretKey(): string { if ($this->isGoogleAuthenticatorEnabled()) { - $secretKey = (string) $this->data['row']['tx_cfgoogleauthenticator_secret']; + $secretKey = (string) $this->data['databaseRow']['tx_cfgoogleauthenticator_secret']; } else { $secretKey = Base32Utility::generateRandomString(16); } @@ -205,10 +207,10 @@ private function getSecretKey(): string private function isGoogleAuthenticatorEnabled(): bool { - if ($this->data['type'] === 'user' && !is_array($this->data['row'])) { - $this->data['row'] = $GLOBALS['BE_USER']->user; + if ($this->data['parameterArray']['fieldConf']['config']['type'] === 'user' && !is_array($this->data['databaseRow'])) { + $this->data['databaseRow'] = $GLOBALS['BE_USER']->user; } - return (bool) $this->data['row']['tx_cfgoogleauthenticator_enabled']; + return (bool) $this->data['databaseRow']['tx_cfgoogleauthenticator_enabled']; } private function getQrCodeGenerator(): QrCodeGeneratorInterface diff --git a/Classes/Hook/UserSettingsProfile.php b/Classes/Hook/UserSettingsProfile.php new file mode 100644 index 0000000..187b423 --- /dev/null +++ b/Classes/Hook/UserSettingsProfile.php @@ -0,0 +1,227 @@ + + * @copyright (c) 2018-2019 by Robin von den Bergen + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version 1.0.0 + * + * @link https://github.com/codeFareith/cf_google_authenticator + * @see https://www.fareith.de + * @see https://typo3.org + */ + +namespace CodeFareith\CfGoogleAuthenticator\Hook; + +use CodeFareith\CfGoogleAuthenticator\Domain\Immutable\AuthenticationSecret; +use CodeFareith\CfGoogleAuthenticator\Service\GoogleQrCodeGenerator; +use CodeFareith\CfGoogleAuthenticator\Service\QrCodeGeneratorInterface; +use CodeFareith\CfGoogleAuthenticator\Traits\GeneralUtilityObjectManager; +use CodeFareith\CfGoogleAuthenticator\Utility\Base32Utility; +use CodeFareith\CfGoogleAuthenticator\Utility\PathUtility; +use Exception; +use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Fluid\View\StandaloneView; +use function sprintf; +use function vsprintf; + +/** + * Hook for the user settings + * + * This class hooks into the backend user settings, + * to extend the view by creating a secret key and an image of + * the QR code for the Google Authenticator. + * + * @package CodeFareith\CfGoogleAuthenticator\Hook + * @since 1.0.0 + */ +class UserSettingsProfile +{ + /*─────────────────────────────────────────────────────────────────────────────*\ + Traits + \*─────────────────────────────────────────────────────────────────────────────*/ + use GeneralUtilityObjectManager; + + /*─────────────────────────────────────────────────────────────────────────────*\ + Properties + \*─────────────────────────────────────────────────────────────────────────────*/ + /** + * @var mixed[] + */ + protected $data; + + /** + * @var AuthenticationSecret + */ + private $authenticationSecret; + + /** + * @var QrCodeGeneratorInterface + */ + private $qrCodeGenerator; + + /*─────────────────────────────────────────────────────────────────────────────*\ + Methods + \*─────────────────────────────────────────────────────────────────────────────*/ + /** + * @param mixed[] $data + * + * @return string + * @throws Exception + */ + public function createSecretField(array $data): string + { + $result = $this->data; + $data = $result; + $authenticationSecret = $this->getAuthenticationSecret(); + $templateView = $this->initializeTemplateView(); + $isEnabled = $this->isGoogleAuthenticatorEnabled(); + $qrCodeUri = $this->getQrCodeGenerator()->generateUri($authenticationSecret); + + $prefix = ''; + if ($this->data['tableName'] !== null) { + $prefix .= sprintf('[%s]', $this->data['tableName']); + } + if ($data['databaseRow']['uid'] !== null) { + $prefix .= sprintf('[%s]', (string)$this->data['databaseRow']['uid']); + } + + $templateView->assignMultiple( + [ + 'prefix' => $prefix, + 'isEnabled' => $isEnabled, + 'qrCodeUri' => $qrCodeUri, + 'authenticatorSecret' => $this->getAuthenticationSecret()->getSecretKey(), + ] + ); + + $result = $templateView->render(); + + return $result; + } + + private function initializeTemplateView(): StandaloneView + { + $templatePath = $this->getTemplatePath(); + + /** @var StandaloneView $templateView */ + $templateView = $this->objectManager()->get(StandaloneView::class); + $templateView->setLayoutRootPaths([$templatePath . 'Layouts/']); + $templateView->setPartialRootPaths([$templatePath . 'Partials/']); + $templateView->setTemplateRootPaths([$templatePath . 'Templates/']); + + $templateView->setTemplatePathAndFilename( + GeneralUtility::getFileAbsFileName( + PathUtility::makeExtensionPath('Resources/Private/Templates/Backend/UserSettings.html') + ) + ); + + return $templateView; + } + + private function getTemplatePath(): string + { + return GeneralUtility::getFileAbsFileName( + PathUtility::makeExtensionPath('Resources/Private/') + ); + } + + private function getIssuer(): string + { + return vsprintf( + '%s - %s', + [ + $this->getSiteName(), + $this->getLayer(), + ] + ); + } + + private function getSiteName(): string + { + return $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; + } + + private function getLayer(): string + { + $layer = ''; + + if ($this->data['tableName'] === 'fe_users') { + $layer = 'Frontend'; + } elseif ($this->data['tableName'] === 'be_users') { + $layer = 'Backend'; + } + + $dispatcher = GeneralUtility::makeInstance(Dispatcher::class); + $signalArguments = [ + 'table' => $this->data['tableName'], + 'layer' => $layer, + 'caller' => $this, + ]; + $signalArguments = $dispatcher->dispatch( + __CLASS__, + 'defineIssuerLayer', + $signalArguments + ); + + return $signalArguments['layer']; + } + + private function getUsername(): string + { + return $this->data['databaseRow']['username'] ?? ''; + } + + /** + * @throws Exception + */ + private function getAuthenticationSecret(): AuthenticationSecret + { + if ($this->authenticationSecret === null) { + $this->authenticationSecret = $this->objectManager()->get( + AuthenticationSecret::class, + $this->getIssuer(), + $this->getUsername(), + $this->getSecretKey() + ); + } + + return $this->authenticationSecret; + } + + /** + * @throws Exception + */ + private function getSecretKey(): string + { + if ($this->isGoogleAuthenticatorEnabled()) { + $secretKey = (string) $this->data['databaseRow']['tx_cfgoogleauthenticator_secret']; + } else { + $secretKey = Base32Utility::generateRandomString(16); + } + + return $secretKey; + } + + private function isGoogleAuthenticatorEnabled(): bool + { + if ($this->data['parameterArray']['fieldConf']['config']['type'] === 'user' && !is_array($this->data['databaseRow'])) { + $this->data['databaseRow'] = $GLOBALS['BE_USER']->user; + } + return (bool) $this->data['databaseRow']['tx_cfgoogleauthenticator_enabled']; + } + + private function getQrCodeGenerator(): QrCodeGeneratorInterface + { + if ($this->qrCodeGenerator === null) { + $this->qrCodeGenerator = $this->objectManager()->get(GoogleQrCodeGenerator::class); + } + + return $this->qrCodeGenerator; + } +} diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php new file mode 100644 index 0000000..7eb2e2c --- /dev/null +++ b/Configuration/Extbase/Persistence/Classes.php @@ -0,0 +1,10 @@ + [ + 'tableName' => 'fe_users', + ], + \CodeFareith\CfGoogleAuthenticator\Domain\Model\BackendUser::class => [ + 'tableName' => 'be_users', + ], +]; diff --git a/Configuration/TCA/Overrides/be_users.php b/Configuration/TCA/Overrides/be_users.php index faeb79e..c1705ed 100644 --- a/Configuration/TCA/Overrides/be_users.php +++ b/Configuration/TCA/Overrides/be_users.php @@ -41,7 +41,7 @@ static function () { ), 'config' => [ 'type' => 'user', - 'userFunc' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettings::class . '->createSecretField', + 'renderType' => 'TwoFactorAuth', ], ], ] diff --git a/Configuration/TCA/Overrides/fe_users.php b/Configuration/TCA/Overrides/fe_users.php index 4e203c2..478bc7e 100644 --- a/Configuration/TCA/Overrides/fe_users.php +++ b/Configuration/TCA/Overrides/fe_users.php @@ -41,7 +41,7 @@ static function () { ), 'config' => [ 'type' => 'user', - 'userFunc' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettings::class . '->createSecretField', + 'renderType' => 'TwoFactorAuth', ], ], ] diff --git a/Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html b/Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html new file mode 100644 index 0000000..b90d3f3 --- /dev/null +++ b/Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Resources/Private/Templates/FeLogin/FrontendLogin.html b/Resources/Private/Templates/FrontendLogin/FrontendLogin.html similarity index 100% rename from Resources/Private/Templates/FeLogin/FrontendLogin.html rename to Resources/Private/Templates/FrontendLogin/FrontendLogin.html diff --git a/Resources/Private/Templates/FrontendLogin/Login/Login.html b/Resources/Private/Templates/FrontendLogin/Login/Login.html new file mode 100644 index 0000000..9660bff --- /dev/null +++ b/Resources/Private/Templates/FrontendLogin/Login/Login.html @@ -0,0 +1,92 @@ + +
+ +

+ +

+
+ + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + +
+
+ + + + + + + +
+
+ + +
+ +
+
+ + + + + + + + + + + +
+
+
+ + + + +
+
+
+ + \ No newline at end of file diff --git a/Resources/Private/Templates/FrontendLogin/Login/Logout.html b/Resources/Private/Templates/FrontendLogin/Login/Logout.html new file mode 100644 index 0000000..ccb0649 --- /dev/null +++ b/Resources/Private/Templates/FrontendLogin/Login/Logout.html @@ -0,0 +1,23 @@ + + +
+ + +
+ + + + + + + + + + +
+ diff --git a/Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html b/Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html new file mode 100644 index 0000000..c9b94ac --- /dev/null +++ b/Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html @@ -0,0 +1,21 @@ + +
+ +

+
+ +
+
+ +
+ + +
+ + + +
+ +
+
+ diff --git a/Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html b/Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html new file mode 100644 index 0000000..8833d61 --- /dev/null +++ b/Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html @@ -0,0 +1,30 @@ + +
+ +

+
+ +
+
+ +
+ +
+
+ + +
+
+ + +
+

+

+ + + +
+ +
+
+ diff --git a/ext_icon.png b/Resources/Public/Icons/Extension.png similarity index 100% rename from ext_icon.png rename to Resources/Public/Icons/Extension.png diff --git a/composer.json b/composer.json index 58f81af..d38151e 100644 --- a/composer.json +++ b/composer.json @@ -46,16 +46,16 @@ "rss": "https://github.com/codeFareith/cf_google_authenticator/commits/master.atom" }, "require": { - "typo3/cms-core": "^8.7 || ^9.5", - "typo3/cms-reports": "^8.7 || ^9.5", - "typo3/cms-setup": "^8.7 || ^9.5", + "typo3/cms-core": "^8.7 || ^9.5 || ^10.4", + "typo3/cms-reports": "^8.7 || ^9.5 || ^10.4", + "typo3/cms-setup": "^8.7 || ^9.5 || ^10.4", "ext-json": "*" }, "require-dev": { "roave/security-advisories": "dev-master", - "typo3/testing-framework": "^3.4.2", + "typo3/testing-framework": "^2.0.1", "phpunit/php-code-coverage": "5.3.2", - "codeception/codeception": "^4.1" + "codeception/codeception": "^3.0" }, "conflict": {}, "replace": { @@ -66,7 +66,6 @@ "suggest": { "typo3/cms-felogin": "Needed to support 2FA for frontend accounts." }, - "autoload": { "psr-0": {}, "psr-4": { @@ -104,7 +103,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.1.x-dev" }, "typo3/cms": { "extension-key": "cf_google_authenticator", @@ -116,4 +115,4 @@ "archive": {}, "abandoned": false, "non-feature-branches": [] -} +} \ No newline at end of file diff --git a/ext_conf_template.txt b/ext_conf_template.txt index f966c9d..c639892 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -6,10 +6,10 @@ googleAuthenticatorEnableBE = 1 # cat=basic/enable; type=boolean; label=LLL:EXT:cf_google_authenticator/Resources/Private/Language/locallang_ect.xlf:basic.googleAuthenticatorEnableFE -googleAuthenticatorEnableFE = 0 +googleAuthenticatorEnableFE = 1 # cat=basic/enable; type=string; label=LLL:EXT:cf_google_authenticator/Resources/Private/Language/locallang_ect.xlf:basic.feLoginTemplate -feLoginTemplate = EXT:cf_google_authenticator/Resources/Private/Templates/FeLogin/FrontendLogin.html +feLoginTemplate = EXT:cf_google_authenticator/Resources/Private/Templates/FrontendLogin/FrontendLogin.html # cat=basic/enable; type=boolean; label=LLL:EXT:cf_google_authenticator/Resources/Private/Language/locallang_ect.xlf:basic.devlog devlog = 0 diff --git a/ext_emconf.php b/ext_emconf.php index 95da051..82b9b72 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -1,4 +1,6 @@ '[codeFareith] Google Authenticator', - 'description' => 'Enable Google 2FA (two factor authentication) for both, frontend- and backend accounts.', - 'category' => 'misc', - - 'author' => 'Robin "codeFareith" von den Bergen', - 'author_email' => 'robin@vondenbergen.de', - 'author_company' => '', - - 'state' => 'stable', - 'version' => '1.2.4', - - 'uploadFolders' => false, - 'createDirs' => '', - 'clearCacheOnLoad' => true, - - 'constraints' => [ - 'depends' => [ - 'php' => '7.1-', - 'typo3' => '8.7.0-9.5.99', - ], - 'conflicts' => [ - ], - 'suggests' => [ - 'felogin' => '8.7.0-9.5.99', - ], + 'title' => '[codeFareith] Google Authenticator', + 'description' => 'Enable Google 2FA (two factor authentication) for both, frontend- and backend accounts.', + 'category' => 'misc', + + 'author' => 'Robin "codeFareith" von den Bergen', + 'author_email' => 'robin@vondenbergen.de', + 'author_company' => '', + + 'state' => 'stable', + 'version' => '1.2.0', + + 'uploadFolders' => false, + 'createDirs' => '', + 'clearCacheOnLoad' => true, + + 'constraints' => [ + 'depends' => [ + 'php' => '7.4-', + 'typo3' => '8.7.0-10.4.99', + ], + 'conflicts' => [], + 'suggests' => [ + 'felogin' => '8.7.0-10.4.99', ], + ], - 'autoload' => [ - 'psr-4' => [ - 'CodeFareith\\CfGoogleAuthenticator\\' => 'Classes', - ], + 'autoload' => [ + 'psr-4' => [ + 'CodeFareith\\CfGoogleAuthenticator\\' => 'Classes', ], - 'autoload-dev' => [ - 'psr-4' => [ - 'CodeFareith\\CfGoogleAuthenticator\\Tests\\' => 'Tests', - ], + ], + 'autoload-dev' => [ + 'psr-4' => [ + 'CodeFareith\\CfGoogleAuthenticator\\Tests\\' => 'Tests', ], + ], ]; diff --git a/ext_localconf.php b/ext_localconf.php index 91a0b32..0e80761 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,4 +1,5 @@ get(\CodeFareith\CfGoogleAuthenticator\Service\GoogleAuthenticationServiceAdapterFactory::class); - $adapter = $adapterFactory->create(); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService( $_EXTKEY, 'auth', @@ -45,7 +40,7 @@ static function ($_EXTKEY) { 'quality' => 80, 'os' => '', 'exec' => '', - 'className' => get_class($adapter), + 'className' => \CodeFareith\CfGoogleAuthenticator\Service\CoreAuthenticationServiceAdapter::class, ] ); @@ -76,26 +71,20 @@ static function ($_EXTKEY) { } if ((bool) $extConf['googleAuthenticatorEnableBE'] === true) { - $globalsReference['TYPO3_CONF_VARS'] - ['EXTCONF'] - ['backend'] - ['loginProviders'] - [1433416747] - ['provider'] = \CodeFareith\CfGoogleAuthenticator\Provider\Login\GoogleAuthenticatorLoginProvider::class; + $globalsReference['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'][1433416747]['provider'] = \CodeFareith\CfGoogleAuthenticator\Provider\Login\GoogleAuthenticatorLoginProvider::class; } - $globalsReference['TYPO3_CONF_VARS'] - ['SC_OPTIONS'] - ['t3lib/class.t3lib_tcemain.php'] - ['processDatamapClass'] - [$_EXTKEY] = \CodeFareith\CfGoogleAuthenticator\Hook\TCEMain::class; + $globalsReference['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][$_EXTKEY] = \CodeFareith\CfGoogleAuthenticator\Hook\TCEMain::class; + + $globalsReference['TYPO3_CONF_VARS']['EXTCONF']['felogin']['postProcContent'][$_EXTKEY] = \CodeFareith\CfGoogleAuthenticator\Hook\FeLogin::class . '->createOneTimePasswordField'; - $globalsReference['TYPO3_CONF_VARS'] - ['EXTCONF'] - ['felogin'] - ['postProcContent'] - [$_EXTKEY] = \CodeFareith\CfGoogleAuthenticator\Hook\FeLogin::class . '->createOneTimePasswordField'; + // Register a node in ext_localconf.php + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1606376982] = [ + 'nodeName' => 'TwoFactorAuth', + 'priority' => 40, + 'class' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettings::class, + ]; }, /** @var string $_EXTKEY */ - $_EXTKEY + 'cf_google_authenticator' ); diff --git a/ext_tables.php b/ext_tables.php index 984f214..885f84f 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,4 +1,5 @@ [ + 'label' => \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( + 'be_users.tx_cfgoogleauthenticator_enabled', + 'locallang_db.xlf' + ), + 'type' => 'check', + 'table' => 'be_users', + ], - if (TYPO3_version >= '9.0.0') { - $globalsReference['TYPO3_USER_SETTINGS']['columns'] = array_merge( - $globalsReference['TYPO3_USER_SETTINGS']['columns'], - [ - 'tx_cfgoogleauthenticator_enabled' => [ - 'label' => \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( - 'be_users.tx_cfgoogleauthenticator_enabled', - 'locallang_db.xlf' - ), - 'type' => 'check', - 'table' => 'be_users', - ], + 'tx_cfgoogleauthenticator_secret' => [ + 'label' => \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( + 'be_users.tx_cfgoogleauthenticator_secret', + 'locallang_db.xlf' + ), + 'type' => 'user', + 'userFunc' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettingsProfile::class . '->createSecretField', + 'table' => 'be_users', + ], + ] + ); - 'tx_cfgoogleauthenticator_secret' => [ - 'label' => \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( - 'be_users.tx_cfgoogleauthenticator_secret', - 'locallang_db.xlf' - ), - 'type' => 'user', - 'userFunc' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettings::class . '->createSecretField', - 'table' => 'be_users', - ], - ] - ); - } \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings( '--div--;' - . \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( - 'tx_cfgoogleauthenticator', - 'locallang_db.xlf' - ) . ', + . \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( + 'tx_cfgoogleauthenticator', + 'locallang_db.xlf' + ) . ', tx_cfgoogleauthenticator_enabled, tx_cfgoogleauthenticator_secret' ); }, /** @var string $_EXTKEY */ - $_EXTKEY + 'cf_google_authenticator' ); From ac79d1acc35afaba52a682df38ec54c3a6918337 Mon Sep 17 00:00:00 2001 From: Shaker Hasan Date: Wed, 9 Mar 2022 11:54:57 +0100 Subject: [PATCH 2/3] [TASK] Adapted all Files to Pull Req #515 XP --- .../Form/Element/TwoFactorAuth.php} | 24 +- .../Controller/Frontend/SetupController.php | 29 ++- .../GoogleAuthenticatorSettingsDTO.php | 2 +- .../PreProcessFieldArrayDTO.php | 2 +- Classes/Domain/Form/FormInterface.php | 2 +- Classes/Domain/Form/SetupForm.php | 2 +- .../Domain/Immutable/AuthenticationSecret.php | 2 +- .../Domain/Immutable/ImmutableInterface.php | 2 +- Classes/Domain/Mapper/AbstractMapper.php | 2 +- .../GoogleAuthenticatorSettingsMapper.php | 2 +- Classes/Domain/Mapper/MapperInterface.php | 2 +- Classes/Domain/Model/BackendUser.php | 2 +- Classes/Domain/Model/FrontendUser.php | 2 +- .../Repository/BackendUserRepository.php | 2 +- .../Repository/FrontendUserRepository.php | 2 +- Classes/Domain/Struct/AbstractStruct.php | 2 +- .../Struct/GoogleAuthenticatorSettings.php | 2 +- Classes/Domain/Struct/StructInterface.php | 2 +- Classes/Exception/MissingRequiredField.php | 2 +- Classes/Exception/PropertyNotFound.php | 2 +- Classes/Exception/PropertyNotInitialized.php | 2 +- .../GoogleAuthenticatorSetupHandler.php | 2 +- Classes/Hook/FeLogin.php | 2 +- Classes/Hook/TCEMain.php | 18 +- Classes/Hook/UserSettings.php | 227 ++---------------- .../GoogleAuthenticatorLoginProvider.php | 2 +- Classes/Service/AuthenticationService.php | 2 +- .../AuthenticationServiceAdapterFactory.php | 2 +- .../CoreAuthenticationServiceAdapter.php | 2 +- ...gleAuthenticationServiceAdapterFactory.php | 65 ----- .../Service/GoogleAuthenticatorService.php | 5 +- Classes/Service/GoogleQrCodeGenerator.php | 2 +- .../LegacyAuthenticationServiceAdapter.php | 54 ----- Classes/Service/QrCodeGeneratorInterface.php | 2 +- .../Traits/GeneralUtilityObjectManager.php | 2 +- Classes/Utility/Base32Utility.php | 2 +- Classes/Utility/ExtensionBasicDataUtility.php | 2 +- .../Utility/GoogleAuthenticatorUtility.php | 2 +- Classes/Utility/PathUtility.php | 2 +- Classes/Utility/TypoScriptUtility.php | 2 +- .../Validator/SetupFormValidator.php | 2 +- Configuration/Extbase/Persistence/Classes.php | 2 +- Configuration/TCA/Overrides/be_users.php | 9 +- Configuration/TCA/Overrides/fe_users.php | 9 +- Configuration/TCA/Overrides/sys_template.php | 2 +- Configuration/TCA/Overrides/tt_content.php | 2 +- Configuration/TypoScript/setup.typoscript | 12 + .../Classes/Domain/Form/SetupForm.php.txt | 2 +- .../Exception/MissingRequiredField.php.txt | 2 +- .../Exception/PropertyNotFound.php.txt | 2 +- .../Exception/PropertyNotInitialized.php.txt | 2 +- .../GoogleAuthenticatorSetupHandler.php.txt | 2 +- .../API/files/Classes/Hook/FeLogin.php.txt | 2 +- .../API/files/Classes/Hook/TCEMain.php.txt | 2 +- .../files/Classes/Hook/UserSettings.php.txt | 2 +- .../Service/GoogleQrCodeGenerator.php.txt | 2 +- .../Service/QrCodeGeneratorInterface.php.txt | 2 +- .../GeneralUtilityObjectManager.php.txt | 2 +- .../Classes/Utility/Base32Utility.php.txt | 2 +- .../Utility/ExtensionBasicDataUtility.php.txt | 2 +- .../GoogleAuthenticatorUtility.php.txt | 2 +- .../files/Classes/Utility/PathUtility.php.txt | 2 +- .../Classes/Utility/TypoScriptUtility.php.txt | 2 +- .../FrontendLogin.html | 0 .../FrontendLogin/Email/PasswordRecovery.html | 11 - .../Templates/FrontendLogin/Login/Login.html | 92 ------- .../Templates/FrontendLogin/Login/Logout.html | 23 -- .../PasswordRecovery/Recovery.html | 21 -- .../PasswordRecovery/ShowChangePassword.html | 30 --- Tests/Build/UnitTests.xml | 1 - Tests/Unit/BaseTestCase.php | 2 +- composer.json | 15 +- ext_conf_template.txt | 4 +- ext_emconf.php | 85 +++---- ext_localconf.php | 23 +- ext_tables.php | 19 +- ext_typoscript_setup.typoscript | 18 -- 77 files changed, 217 insertions(+), 685 deletions(-) rename Classes/{Hook/UserSettingsProfile.php => Backend/Form/Element/TwoFactorAuth.php} (94%) delete mode 100644 Classes/Service/GoogleAuthenticationServiceAdapterFactory.php delete mode 100644 Classes/Service/LegacyAuthenticationServiceAdapter.php rename Resources/Private/Templates/{FrontendLogin => FeLogin}/FrontendLogin.html (100%) delete mode 100644 Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html delete mode 100644 Resources/Private/Templates/FrontendLogin/Login/Login.html delete mode 100644 Resources/Private/Templates/FrontendLogin/Login/Logout.html delete mode 100644 Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html delete mode 100644 Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html delete mode 100644 ext_typoscript_setup.typoscript diff --git a/Classes/Hook/UserSettingsProfile.php b/Classes/Backend/Form/Element/TwoFactorAuth.php similarity index 94% rename from Classes/Hook/UserSettingsProfile.php rename to Classes/Backend/Form/Element/TwoFactorAuth.php index 187b423..27c7e78 100644 --- a/Classes/Hook/UserSettingsProfile.php +++ b/Classes/Backend/Form/Element/TwoFactorAuth.php @@ -1,11 +1,12 @@ - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * @@ -14,7 +15,7 @@ * @see https://typo3.org */ -namespace CodeFareith\CfGoogleAuthenticator\Hook; +namespace CodeFareith\CfGoogleAuthenticator\Backend\Form\Element; use CodeFareith\CfGoogleAuthenticator\Domain\Immutable\AuthenticationSecret; use CodeFareith\CfGoogleAuthenticator\Service\GoogleQrCodeGenerator; @@ -23,15 +24,15 @@ use CodeFareith\CfGoogleAuthenticator\Utility\Base32Utility; use CodeFareith\CfGoogleAuthenticator\Utility\PathUtility; use Exception; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; -use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; use TYPO3\CMS\Fluid\View\StandaloneView; use function sprintf; use function vsprintf; +use TYPO3\CMS\Backend\Form\Element\AbstractFormElement; /** - * Hook for the user settings + * Custom field for the OTP setup in TCA * * This class hooks into the backend user settings, * to extend the view by creating a secret key and an image of @@ -40,7 +41,7 @@ * @package CodeFareith\CfGoogleAuthenticator\Hook * @since 1.0.0 */ -class UserSettingsProfile +class TwoFactorAuth extends AbstractFormElement { /*─────────────────────────────────────────────────────────────────────────────*\ Traits @@ -69,15 +70,12 @@ class UserSettingsProfile Methods \*─────────────────────────────────────────────────────────────────────────────*/ /** - * @param mixed[] $data - * - * @return string + * @return array * @throws Exception */ - public function createSecretField(array $data): string + public function render(): array { - $result = $this->data; - $data = $result; + $result = $this->initializeResultArray(); $authenticationSecret = $this->getAuthenticationSecret(); $templateView = $this->initializeTemplateView(); $isEnabled = $this->isGoogleAuthenticatorEnabled(); @@ -100,7 +98,7 @@ public function createSecretField(array $data): string ] ); - $result = $templateView->render(); + $result['html'] = $templateView->render(); return $result; } diff --git a/Classes/Controller/Frontend/SetupController.php b/Classes/Controller/Frontend/SetupController.php index f3ef61c..9393fec 100644 --- a/Classes/Controller/Frontend/SetupController.php +++ b/Classes/Controller/Frontend/SetupController.php @@ -3,7 +3,7 @@ * Class SetupController * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * @@ -34,6 +34,7 @@ use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; use function get_class; use function vsprintf; @@ -82,6 +83,11 @@ class SetupController */ private $authenticationSecret; + /** + * @var Dispatcher + */ + protected $dispatcher; + /*─────────────────────────────────────────────────────────────────────────────*\ Methods \*─────────────────────────────────────────────────────────────────────────────*/ @@ -90,16 +96,16 @@ public function __construct( GoogleQrCodeGenerator $qrCodeGenerator, SetupFormValidator $setupFormValidator, LanguageService $languageService, - Context $context + Context $context, + Dispatcher $dispatcher ) { - //parent::__construct(); - $this->frontendUserRepository = $frontendUserRepository; $this->qrCodeGenerator = $qrCodeGenerator; $this->setupFormValidator = $setupFormValidator; $this->languageService = $languageService; $this->context = $context; + $this->dispatcher = $dispatcher; } /** @@ -153,16 +159,31 @@ public function updateAction(): void if ($user !== null) { $formData = (array)$this->request->getArgument(SetupForm::FORM_NAME); + $action = null; if ($this->request->hasArgument('enable')) { $user->enableGoogleAuthenticator($formData['secret']); + $action = 'enable'; } elseif ($this->request->hasArgument('disable')) { $user->disableGoogleAuthenticator(); + $action = 'disable'; } $this->frontendUserRepository->update($user); $this->addSuccessMessage(); + if ($action !== null) { + $this->dispatcher->dispatch( + __CLASS__, + 'toggleGoogleAuthenticator', + [ + 'action' => $action, + 'user' => $user, + 'caller' => $this, + ] + ); + } + $this->redirect('index'); } } diff --git a/Classes/Domain/DataTransferObject/GoogleAuthenticatorSettingsDTO.php b/Classes/Domain/DataTransferObject/GoogleAuthenticatorSettingsDTO.php index 8994bc3..45166fa 100644 --- a/Classes/Domain/DataTransferObject/GoogleAuthenticatorSettingsDTO.php +++ b/Classes/Domain/DataTransferObject/GoogleAuthenticatorSettingsDTO.php @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorSettingsDTO * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/DataTransferObject/PreProcessFieldArrayDTO.php b/Classes/Domain/DataTransferObject/PreProcessFieldArrayDTO.php index d10a86b..caa2479 100644 --- a/Classes/Domain/DataTransferObject/PreProcessFieldArrayDTO.php +++ b/Classes/Domain/DataTransferObject/PreProcessFieldArrayDTO.php @@ -3,7 +3,7 @@ * Class PreProcessFieldArrayDTO * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Form/FormInterface.php b/Classes/Domain/Form/FormInterface.php index 1d5f2c1..3e628f5 100644 --- a/Classes/Domain/Form/FormInterface.php +++ b/Classes/Domain/Form/FormInterface.php @@ -3,7 +3,7 @@ * Interface FormInterface * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Form/SetupForm.php b/Classes/Domain/Form/SetupForm.php index 24c66e0..c01aed7 100644 --- a/Classes/Domain/Form/SetupForm.php +++ b/Classes/Domain/Form/SetupForm.php @@ -3,7 +3,7 @@ * Class SetupForm * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Immutable/AuthenticationSecret.php b/Classes/Domain/Immutable/AuthenticationSecret.php index 43829a5..6d9bebf 100644 --- a/Classes/Domain/Immutable/AuthenticationSecret.php +++ b/Classes/Domain/Immutable/AuthenticationSecret.php @@ -3,7 +3,7 @@ * Class AuthenticationSecret * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Immutable/ImmutableInterface.php b/Classes/Domain/Immutable/ImmutableInterface.php index 141f7de..68dd745 100644 --- a/Classes/Domain/Immutable/ImmutableInterface.php +++ b/Classes/Domain/Immutable/ImmutableInterface.php @@ -3,7 +3,7 @@ * Interface ImmutableInterface * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Mapper/AbstractMapper.php b/Classes/Domain/Mapper/AbstractMapper.php index 1f4d27c..c8964e9 100644 --- a/Classes/Domain/Mapper/AbstractMapper.php +++ b/Classes/Domain/Mapper/AbstractMapper.php @@ -3,7 +3,7 @@ * Class AbstractMapper * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Mapper/GoogleAuthenticatorSettingsMapper.php b/Classes/Domain/Mapper/GoogleAuthenticatorSettingsMapper.php index 90514f8..8ba4ac7 100644 --- a/Classes/Domain/Mapper/GoogleAuthenticatorSettingsMapper.php +++ b/Classes/Domain/Mapper/GoogleAuthenticatorSettingsMapper.php @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorSettingsMapper * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Mapper/MapperInterface.php b/Classes/Domain/Mapper/MapperInterface.php index fc74c36..f298404 100644 --- a/Classes/Domain/Mapper/MapperInterface.php +++ b/Classes/Domain/Mapper/MapperInterface.php @@ -3,7 +3,7 @@ * Interface MapperInterface * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Model/BackendUser.php b/Classes/Domain/Model/BackendUser.php index 4825bb3..b18d992 100644 --- a/Classes/Domain/Model/BackendUser.php +++ b/Classes/Domain/Model/BackendUser.php @@ -3,7 +3,7 @@ * Class BackendUser * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index 551f63f..8182975 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -3,7 +3,7 @@ * Class FrontendUser * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Repository/BackendUserRepository.php b/Classes/Domain/Repository/BackendUserRepository.php index 6e73ea2..bfb9ae8 100644 --- a/Classes/Domain/Repository/BackendUserRepository.php +++ b/Classes/Domain/Repository/BackendUserRepository.php @@ -3,7 +3,7 @@ * Class BackendUserRepository * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Repository/FrontendUserRepository.php b/Classes/Domain/Repository/FrontendUserRepository.php index 5b702c5..567eb42 100644 --- a/Classes/Domain/Repository/FrontendUserRepository.php +++ b/Classes/Domain/Repository/FrontendUserRepository.php @@ -3,7 +3,7 @@ * Class FrontendUserRepository * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Struct/AbstractStruct.php b/Classes/Domain/Struct/AbstractStruct.php index 039c63e..6816dc7 100644 --- a/Classes/Domain/Struct/AbstractStruct.php +++ b/Classes/Domain/Struct/AbstractStruct.php @@ -3,7 +3,7 @@ * Class AbstractStruct * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Struct/GoogleAuthenticatorSettings.php b/Classes/Domain/Struct/GoogleAuthenticatorSettings.php index 55ad621..6cdf528 100644 --- a/Classes/Domain/Struct/GoogleAuthenticatorSettings.php +++ b/Classes/Domain/Struct/GoogleAuthenticatorSettings.php @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorSettings * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Domain/Struct/StructInterface.php b/Classes/Domain/Struct/StructInterface.php index c58d9ab..9455cdd 100644 --- a/Classes/Domain/Struct/StructInterface.php +++ b/Classes/Domain/Struct/StructInterface.php @@ -3,7 +3,7 @@ * Interface StructInterface * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Exception/MissingRequiredField.php b/Classes/Exception/MissingRequiredField.php index 8f34588..3dfe9f1 100644 --- a/Classes/Exception/MissingRequiredField.php +++ b/Classes/Exception/MissingRequiredField.php @@ -3,7 +3,7 @@ * Class MissingRequiredField * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Exception/PropertyNotFound.php b/Classes/Exception/PropertyNotFound.php index 7cc81ad..542cbd3 100644 --- a/Classes/Exception/PropertyNotFound.php +++ b/Classes/Exception/PropertyNotFound.php @@ -3,7 +3,7 @@ * Class PropertyNotFound * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Exception/PropertyNotInitialized.php b/Classes/Exception/PropertyNotInitialized.php index 1b310cc..a564afe 100644 --- a/Classes/Exception/PropertyNotInitialized.php +++ b/Classes/Exception/PropertyNotInitialized.php @@ -3,7 +3,7 @@ * Class PropertyNotInitialized * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Handler/GoogleAuthenticatorSetupHandler.php b/Classes/Handler/GoogleAuthenticatorSetupHandler.php index f792d61..620700c 100644 --- a/Classes/Handler/GoogleAuthenticatorSetupHandler.php +++ b/Classes/Handler/GoogleAuthenticatorSetupHandler.php @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorSetupHandler * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Hook/FeLogin.php b/Classes/Hook/FeLogin.php index 404df00..c94425c 100644 --- a/Classes/Hook/FeLogin.php +++ b/Classes/Hook/FeLogin.php @@ -3,7 +3,7 @@ * Class FeLogin * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Hook/TCEMain.php b/Classes/Hook/TCEMain.php index ebbb449..60cd243 100644 --- a/Classes/Hook/TCEMain.php +++ b/Classes/Hook/TCEMain.php @@ -3,7 +3,7 @@ * Class TCEMain * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * @@ -54,7 +54,7 @@ class TCEMain /** * @noinspection MoreThanThreeArgumentsInspection * - * @param mixed $fieldArray + * @param mixed $fieldArray * @param string|int $id * * @throws MissingRequiredField @@ -69,20 +69,20 @@ public function processDatamap_preProcessFieldArray( ): void { $otpInFieldArray = &$fieldArray['tx_cfgoogleauthenticator_otp']; - $otpInPostData = $_POST['data']['be_users']['tx_cfgoogleauthenticator_otp']; + $otpInPostData = $_POST['data'][$table]['tx_cfgoogleauthenticator_otp']; if ($otpInFieldArray === null && $otpInPostData !== null) { $otpInFieldArray = $otpInPostData; } - $otpInFieldArray2 = &$fieldArray['tx_cfgoogleauthenticator_secret']; - $otpInPostData2 = $_POST['data']['be_users']['tx_cfgoogleauthenticator_secret']; + $secretInFieldArray = &$fieldArray['tx_cfgoogleauthenticator_secret']; + $secretInPostData = $_POST['data'][$table]['tx_cfgoogleauthenticator_secret']; - if ($otpInFieldArray2 === null && $otpInPostData2 !== null) { - $otpInFieldArray2 = $otpInPostData2; - } + if ($secretInFieldArray === null && $secretInPostData !== null) { + $secretInFieldArray = $secretInPostData; + } - $preProcessFieldArrayDTO = $this->getPreProcessFieldArrayDTO($fieldArray, $table, (int) $id, $dataHandler); + $preProcessFieldArrayDTO = $this->getPreProcessFieldArrayDTO($fieldArray, $table, (int)$id, $dataHandler); $result = $this->getGoogleAuthenticatorSetupHandler()->process($preProcessFieldArrayDTO); $fieldArray = array_merge($fieldArray, $result); diff --git a/Classes/Hook/UserSettings.php b/Classes/Hook/UserSettings.php index c544c98..217f479 100644 --- a/Classes/Hook/UserSettings.php +++ b/Classes/Hook/UserSettings.php @@ -1,224 +1,27 @@ - - * @copyright (c) 2018-2019 by Robin von den Bergen - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - * @version 1.0.0 - * - * @link https://github.com/codeFareith/cf_google_authenticator - * @see https://www.fareith.de - * @see https://typo3.org - */ +initializeResultArray(); - $authenticationSecret = $this->getAuthenticationSecret(); - $templateView = $this->initializeTemplateView(); - $isEnabled = $this->isGoogleAuthenticatorEnabled(); - $qrCodeUri = $this->getQrCodeGenerator()->generateUri($authenticationSecret); - - $prefix = ''; - if ($this->data['tableName'] !== null) { - $prefix .= sprintf('[%s]', $this->data['tableName']); - } - if ($data['databaseRow']['uid'] !== null) { - $prefix .= sprintf('[%s]', (string)$this->data['databaseRow']['uid']); - } - - $templateView->assignMultiple( - [ - 'prefix' => $prefix, - 'isEnabled' => $isEnabled, - 'qrCodeUri' => $qrCodeUri, - 'authenticatorSecret' => $this->getAuthenticationSecret()->getSecretKey(), - ] - ); - - $result['html'] = $templateView->render(); - - return $result; - } - - private function initializeTemplateView(): StandaloneView - { - $templatePath = $this->getTemplatePath(); - - /** @var StandaloneView $templateView */ - $templateView = $this->objectManager()->get(StandaloneView::class); - $templateView->setLayoutRootPaths([$templatePath . 'Layouts/']); - $templateView->setPartialRootPaths([$templatePath . 'Partials/']); - $templateView->setTemplateRootPaths([$templatePath . 'Templates/']); - - $templateView->setTemplatePathAndFilename( - GeneralUtility::getFileAbsFileName( - PathUtility::makeExtensionPath('Resources/Private/Templates/Backend/UserSettings.html') - ) - ); - - return $templateView; - } - - private function getTemplatePath(): string - { - return GeneralUtility::getFileAbsFileName( - PathUtility::makeExtensionPath('Resources/Private/') - ); - } - - private function getIssuer(): string - { - return vsprintf( - '%s - %s', - [ - $this->getSiteName(), - $this->getLayer(), - ] - ); - } - - private function getSiteName(): string - { - return $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; - } - - private function getLayer(): string + public function createSecretField(array $config, SetupModuleController $pObj) { - $layer = ''; - - if ($this->data['tableName'] === 'fe_users') { - $layer = 'Frontend'; - } elseif ($this->data['tableName'] === 'be_users') { - $layer = 'Backend'; - } - - $dispatcher = GeneralUtility::makeInstance(Dispatcher::class); - $signalArguments = [ - 'table' => $this->data['tableName'], - 'layer' => $layer, - 'caller' => $this, + /** @var \TYPO3\CMS\Backend\Form\NodeFactory $nodeFactory */ + $nodeFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\NodeFactory::class); + $data = [ + 'tableName' => 'be_users', + 'databaseRow' => $GLOBALS['BE_USER']->user, ]; - $signalArguments = $dispatcher->dispatch( - __CLASS__, - 'defineIssuerLayer', - $signalArguments - ); - return $signalArguments['layer']; - } - - private function getUsername(): string - { - return $this->data['databaseRow']['username'] ?? ''; - } - - /** - * @throws Exception - */ - private function getAuthenticationSecret(): AuthenticationSecret - { - if ($this->authenticationSecret === null) { - $this->authenticationSecret = $this->objectManager()->get( - AuthenticationSecret::class, - $this->getIssuer(), - $this->getUsername(), - $this->getSecretKey() - ); - } - - return $this->authenticationSecret; - } - - /** - * @throws Exception - */ - private function getSecretKey(): string - { - if ($this->isGoogleAuthenticatorEnabled()) { - $secretKey = (string) $this->data['databaseRow']['tx_cfgoogleauthenticator_secret']; - } else { - $secretKey = Base32Utility::generateRandomString(16); - } - - return $secretKey; - } - - private function isGoogleAuthenticatorEnabled(): bool - { - if ($this->data['parameterArray']['fieldConf']['config']['type'] === 'user' && !is_array($this->data['databaseRow'])) { - $this->data['databaseRow'] = $GLOBALS['BE_USER']->user; - } - return (bool) $this->data['databaseRow']['tx_cfgoogleauthenticator_enabled']; - } - - private function getQrCodeGenerator(): QrCodeGeneratorInterface - { - if ($this->qrCodeGenerator === null) { - $this->qrCodeGenerator = $this->objectManager()->get(GoogleQrCodeGenerator::class); - } + $twoFactorAuthElement = GeneralUtility::makeInstance(TwoFactorAuth::class, $nodeFactory, $data); - return $this->qrCodeGenerator; + $result = $twoFactorAuthElement->render(); + return $result['html']; } } diff --git a/Classes/Provider/Login/GoogleAuthenticatorLoginProvider.php b/Classes/Provider/Login/GoogleAuthenticatorLoginProvider.php index 5a1e0bb..e647c5a 100644 --- a/Classes/Provider/Login/GoogleAuthenticatorLoginProvider.php +++ b/Classes/Provider/Login/GoogleAuthenticatorLoginProvider.php @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorLoginProvider * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Service/AuthenticationService.php b/Classes/Service/AuthenticationService.php index ca01aeb..831edb2 100644 --- a/Classes/Service/AuthenticationService.php +++ b/Classes/Service/AuthenticationService.php @@ -3,7 +3,7 @@ * Interface AuthenticationService * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Service/AuthenticationServiceAdapterFactory.php b/Classes/Service/AuthenticationServiceAdapterFactory.php index 665613a..7212e9f 100644 --- a/Classes/Service/AuthenticationServiceAdapterFactory.php +++ b/Classes/Service/AuthenticationServiceAdapterFactory.php @@ -3,7 +3,7 @@ * Interface AuthenticationServiceAdapterFactory * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Service/CoreAuthenticationServiceAdapter.php b/Classes/Service/CoreAuthenticationServiceAdapter.php index 005972e..47211d9 100644 --- a/Classes/Service/CoreAuthenticationServiceAdapter.php +++ b/Classes/Service/CoreAuthenticationServiceAdapter.php @@ -3,7 +3,7 @@ * Class CoreAuthenticationServiceAdapter * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Service/GoogleAuthenticationServiceAdapterFactory.php b/Classes/Service/GoogleAuthenticationServiceAdapterFactory.php deleted file mode 100644 index 8fc9df2..0000000 --- a/Classes/Service/GoogleAuthenticationServiceAdapterFactory.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright (c) 2018-2019 by Robin von den Bergen - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - * @version 1.0.0 - * - * @link https://github.com/codeFareith/cf_google_authenticator - * @see https://www.fareith.de - * @see https://typo3.org - */ - -namespace CodeFareith\CfGoogleAuthenticator\Service; - -use TYPO3\CMS\Core\Utility\VersionNumberUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; -use function version_compare; - -/** - * @package CodeFareith\CfGoogleAuthenticator\Service - * @since 1.1.5 - */ -class GoogleAuthenticationServiceAdapterFactory - implements AuthenticationServiceAdapterFactory -{ - protected $objectManager; - - public function __construct(ObjectManager $objectManager) - { - $this->objectManager = $objectManager; - } - - public function create(): AuthenticationService - { - return $this->objectManager->get( - $this->suggestServiceAdapter(), - $this->suggestAuthenticatorService() - ); - } - - private function suggestServiceAdapter(): string - { - if ($this->isLegacyInstallation()) { - $serviceAdapter = LegacyAuthenticationServiceAdapter::class; - } else { - $serviceAdapter = CoreAuthenticationServiceAdapter::class; - } - - return $serviceAdapter; - } - - private function isLegacyInstallation(): bool - { - $version = VersionNumberUtility::getNumericTypo3Version(); - - return version_compare($version, '9.0.0', '<'); - } - - private function suggestAuthenticatorService(): AuthenticationService - { - return $this->objectManager->get(GoogleAuthenticatorService::class); - } -} diff --git a/Classes/Service/GoogleAuthenticatorService.php b/Classes/Service/GoogleAuthenticatorService.php index 53848c8..da7cdf2 100644 --- a/Classes/Service/GoogleAuthenticatorService.php +++ b/Classes/Service/GoogleAuthenticatorService.php @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorService * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * @@ -73,7 +73,8 @@ public function authUser(array $user): int $logArgs ); - $otp = GeneralUtility::_GP('google-authenticator-otp'); + // TODO: Bypass OTP check in case we try to access the Install Tool? Or add support for OTP in prompt? + $otp = GeneralUtility::_GP('google-authenticator-otp') ?? ''; $secret = $user['tx_cfgoogleauthenticator_secret']; if (GoogleAuthenticatorUtility::verifyOneTimePassword($secret, $otp) === true) { diff --git a/Classes/Service/GoogleQrCodeGenerator.php b/Classes/Service/GoogleQrCodeGenerator.php index 5983ca1..79cac0b 100644 --- a/Classes/Service/GoogleQrCodeGenerator.php +++ b/Classes/Service/GoogleQrCodeGenerator.php @@ -3,7 +3,7 @@ * Class GoogleQrImageGenerator * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Service/LegacyAuthenticationServiceAdapter.php b/Classes/Service/LegacyAuthenticationServiceAdapter.php deleted file mode 100644 index db0ec03..0000000 --- a/Classes/Service/LegacyAuthenticationServiceAdapter.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright (c) 2018-2019 by Robin von den Bergen - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - * @version 1.0.0 - * - * @link https://github.com/codeFareith/cf_google_authenticator - * @see https://www.fareith.de - * @see https://typo3.org - */ - -namespace CodeFareith\CfGoogleAuthenticator\Service; - -use TYPO3\CMS\Sv\AuthenticationService as SvAuthenticationService; - -/** @noinspection LongInheritanceChainInspection */ - -/** - * @package CodeFareith\CfGoogleAuthenticator\Service - * @since 1.1.5 - */ -class LegacyAuthenticationServiceAdapter - extends SvAuthenticationService - implements AuthenticationService -{ - /** - * @var AuthenticationService - */ - protected $service; - - public function __construct(AuthenticationService $authenticationService = null) - { - $authenticationService = $authenticationService ?? new GoogleAuthenticatorService(); - - $this->service = $authenticationService; - } - - public function init(): bool - { - return ( - parent::init() - && $this->service->init() - ); - } - - public function authUser(array $user): int - { - parent::authUser($user); - return $this->service->authUser($user); - } -} diff --git a/Classes/Service/QrCodeGeneratorInterface.php b/Classes/Service/QrCodeGeneratorInterface.php index 298d5c3..1759b45 100644 --- a/Classes/Service/QrCodeGeneratorInterface.php +++ b/Classes/Service/QrCodeGeneratorInterface.php @@ -3,7 +3,7 @@ * Interface QrImageGeneratorInterface * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Traits/GeneralUtilityObjectManager.php b/Classes/Traits/GeneralUtilityObjectManager.php index 976d172..acf32c5 100644 --- a/Classes/Traits/GeneralUtilityObjectManager.php +++ b/Classes/Traits/GeneralUtilityObjectManager.php @@ -3,7 +3,7 @@ * Trait GeneralUtilityObjectManager * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Utility/Base32Utility.php b/Classes/Utility/Base32Utility.php index 6a6c0c7..dd761e2 100644 --- a/Classes/Utility/Base32Utility.php +++ b/Classes/Utility/Base32Utility.php @@ -3,7 +3,7 @@ * Class Base32Utility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Utility/ExtensionBasicDataUtility.php b/Classes/Utility/ExtensionBasicDataUtility.php index 110c852..2a8e305 100644 --- a/Classes/Utility/ExtensionBasicDataUtility.php +++ b/Classes/Utility/ExtensionBasicDataUtility.php @@ -3,7 +3,7 @@ * Class ExtensionBasicDataUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Utility/GoogleAuthenticatorUtility.php b/Classes/Utility/GoogleAuthenticatorUtility.php index e5135f6..0931c6b 100644 --- a/Classes/Utility/GoogleAuthenticatorUtility.php +++ b/Classes/Utility/GoogleAuthenticatorUtility.php @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Utility/PathUtility.php b/Classes/Utility/PathUtility.php index 517f249..aa631b1 100644 --- a/Classes/Utility/PathUtility.php +++ b/Classes/Utility/PathUtility.php @@ -3,7 +3,7 @@ * Class PathUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Utility/TypoScriptUtility.php b/Classes/Utility/TypoScriptUtility.php index 8a2e8a0..98f6881 100644 --- a/Classes/Utility/TypoScriptUtility.php +++ b/Classes/Utility/TypoScriptUtility.php @@ -3,7 +3,7 @@ * Class TypoScriptUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Classes/Validation/Validator/SetupFormValidator.php b/Classes/Validation/Validator/SetupFormValidator.php index 5b8fd6f..59e0d4a 100644 --- a/Classes/Validation/Validator/SetupFormValidator.php +++ b/Classes/Validation/Validator/SetupFormValidator.php @@ -3,7 +3,7 @@ * Class SetupFormValidator * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php index 7eb2e2c..8adc467 100644 --- a/Configuration/Extbase/Persistence/Classes.php +++ b/Configuration/Extbase/Persistence/Classes.php @@ -5,6 +5,6 @@ 'tableName' => 'fe_users', ], \CodeFareith\CfGoogleAuthenticator\Domain\Model\BackendUser::class => [ - 'tableName' => 'be_users', + 'tableName' => 'be_users', ], ]; diff --git a/Configuration/TCA/Overrides/be_users.php b/Configuration/TCA/Overrides/be_users.php index c1705ed..27b129b 100644 --- a/Configuration/TCA/Overrides/be_users.php +++ b/Configuration/TCA/Overrides/be_users.php @@ -6,7 +6,7 @@ * are represented and handled in the TYPO3 backend. * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * @@ -31,6 +31,13 @@ static function () { ), 'config' => [ 'type' => 'check', + 'renderType' => 'checkboxToggle', + 'items' => [ + [ + 0 => '', + 1 => '', + ] + ], ], ], 'tx_cfgoogleauthenticator_secret' => [ diff --git a/Configuration/TCA/Overrides/fe_users.php b/Configuration/TCA/Overrides/fe_users.php index 478bc7e..5f57a7c 100644 --- a/Configuration/TCA/Overrides/fe_users.php +++ b/Configuration/TCA/Overrides/fe_users.php @@ -6,7 +6,7 @@ * are represented and handled in the TYPO3 backend. * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * @@ -31,6 +31,13 @@ static function () { ), 'config' => [ 'type' => 'check', + 'renderType' => 'checkboxToggle', + 'items' => [ + [ + 0 => '', + 1 => '', + ] + ], ], ], 'tx_cfgoogleauthenticator_secret' => [ diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 07a6035..fa4901c 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -6,7 +6,7 @@ * are represented and handled in the TYPO3 backend. * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index af48d7b..310b17d 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -5,7 +5,7 @@ * This script extends the tt_content * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 907281d..f5a0f8a 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -14,5 +14,17 @@ plugin { 1 = {$plugin.tx_cfgoogleauthenticator_setup.view.templateRootPath} } } + + # Persistence mapping is required for TYPO3 v9 + # (in TYPO3 v10, this has moved to EXT:cf_google_authenticator/Configuration/Extbase/Persistence/Classes.php) + persistence { + classes { + CodeFareith\CfGoogleAuthenticator\Domain\Model\FrontendUser { + mapping { + tableName = fe_users + } + } + } + } } } diff --git a/Documentation/API/files/Classes/Domain/Form/SetupForm.php.txt b/Documentation/API/files/Classes/Domain/Form/SetupForm.php.txt index ba22f08..541f983 100644 --- a/Documentation/API/files/Classes/Domain/Form/SetupForm.php.txt +++ b/Documentation/API/files/Classes/Domain/Form/SetupForm.php.txt @@ -3,7 +3,7 @@ * Class SetupForm * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Exception/MissingRequiredField.php.txt b/Documentation/API/files/Classes/Exception/MissingRequiredField.php.txt index ba89837..b91f011 100644 --- a/Documentation/API/files/Classes/Exception/MissingRequiredField.php.txt +++ b/Documentation/API/files/Classes/Exception/MissingRequiredField.php.txt @@ -3,7 +3,7 @@ * Class MissingRequiredField * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Exception/PropertyNotFound.php.txt b/Documentation/API/files/Classes/Exception/PropertyNotFound.php.txt index 396fd09..4bca28f 100644 --- a/Documentation/API/files/Classes/Exception/PropertyNotFound.php.txt +++ b/Documentation/API/files/Classes/Exception/PropertyNotFound.php.txt @@ -3,7 +3,7 @@ * Class PropertyNotFound * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Exception/PropertyNotInitialized.php.txt b/Documentation/API/files/Classes/Exception/PropertyNotInitialized.php.txt index 71fb045..67b1fc6 100644 --- a/Documentation/API/files/Classes/Exception/PropertyNotInitialized.php.txt +++ b/Documentation/API/files/Classes/Exception/PropertyNotInitialized.php.txt @@ -3,7 +3,7 @@ * Class PropertyNotInitialized * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Handler/GoogleAuthenticatorSetupHandler.php.txt b/Documentation/API/files/Classes/Handler/GoogleAuthenticatorSetupHandler.php.txt index 6feaca5..4688288 100644 --- a/Documentation/API/files/Classes/Handler/GoogleAuthenticatorSetupHandler.php.txt +++ b/Documentation/API/files/Classes/Handler/GoogleAuthenticatorSetupHandler.php.txt @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorSetupHandler * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Hook/FeLogin.php.txt b/Documentation/API/files/Classes/Hook/FeLogin.php.txt index da0ab31..3abc6da 100644 --- a/Documentation/API/files/Classes/Hook/FeLogin.php.txt +++ b/Documentation/API/files/Classes/Hook/FeLogin.php.txt @@ -3,7 +3,7 @@ * Class FeLogin * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Hook/TCEMain.php.txt b/Documentation/API/files/Classes/Hook/TCEMain.php.txt index a21ebd5..2bdc0f8 100644 --- a/Documentation/API/files/Classes/Hook/TCEMain.php.txt +++ b/Documentation/API/files/Classes/Hook/TCEMain.php.txt @@ -3,7 +3,7 @@ * Class TCEMain * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Hook/UserSettings.php.txt b/Documentation/API/files/Classes/Hook/UserSettings.php.txt index 4207eb3..9715c13 100644 --- a/Documentation/API/files/Classes/Hook/UserSettings.php.txt +++ b/Documentation/API/files/Classes/Hook/UserSettings.php.txt @@ -3,7 +3,7 @@ * Class UserSettings * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Service/GoogleQrCodeGenerator.php.txt b/Documentation/API/files/Classes/Service/GoogleQrCodeGenerator.php.txt index 09eceef..b6912a2 100644 --- a/Documentation/API/files/Classes/Service/GoogleQrCodeGenerator.php.txt +++ b/Documentation/API/files/Classes/Service/GoogleQrCodeGenerator.php.txt @@ -3,7 +3,7 @@ * Class GoogleQrImageGenerator * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Service/QrCodeGeneratorInterface.php.txt b/Documentation/API/files/Classes/Service/QrCodeGeneratorInterface.php.txt index 859e423..155140d 100644 --- a/Documentation/API/files/Classes/Service/QrCodeGeneratorInterface.php.txt +++ b/Documentation/API/files/Classes/Service/QrCodeGeneratorInterface.php.txt @@ -3,7 +3,7 @@ * Interface QrImageGeneratorInterface * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Traits/GeneralUtilityObjectManager.php.txt b/Documentation/API/files/Classes/Traits/GeneralUtilityObjectManager.php.txt index 033183c..562366e 100644 --- a/Documentation/API/files/Classes/Traits/GeneralUtilityObjectManager.php.txt +++ b/Documentation/API/files/Classes/Traits/GeneralUtilityObjectManager.php.txt @@ -3,7 +3,7 @@ * Trait GeneralUtilityObjectManager * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Utility/Base32Utility.php.txt b/Documentation/API/files/Classes/Utility/Base32Utility.php.txt index d90dfcb..c4f67db 100644 --- a/Documentation/API/files/Classes/Utility/Base32Utility.php.txt +++ b/Documentation/API/files/Classes/Utility/Base32Utility.php.txt @@ -3,7 +3,7 @@ * Class Base32Utility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Utility/ExtensionBasicDataUtility.php.txt b/Documentation/API/files/Classes/Utility/ExtensionBasicDataUtility.php.txt index 31f5747..ff7e634 100644 --- a/Documentation/API/files/Classes/Utility/ExtensionBasicDataUtility.php.txt +++ b/Documentation/API/files/Classes/Utility/ExtensionBasicDataUtility.php.txt @@ -3,7 +3,7 @@ * Class ExtensionBasicDataUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Utility/GoogleAuthenticatorUtility.php.txt b/Documentation/API/files/Classes/Utility/GoogleAuthenticatorUtility.php.txt index e97b7e5..9e744dc 100644 --- a/Documentation/API/files/Classes/Utility/GoogleAuthenticatorUtility.php.txt +++ b/Documentation/API/files/Classes/Utility/GoogleAuthenticatorUtility.php.txt @@ -3,7 +3,7 @@ * Class GoogleAuthenticatorUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Utility/PathUtility.php.txt b/Documentation/API/files/Classes/Utility/PathUtility.php.txt index 0b4efef..54cbf24 100644 --- a/Documentation/API/files/Classes/Utility/PathUtility.php.txt +++ b/Documentation/API/files/Classes/Utility/PathUtility.php.txt @@ -3,7 +3,7 @@ * Class PathUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Documentation/API/files/Classes/Utility/TypoScriptUtility.php.txt b/Documentation/API/files/Classes/Utility/TypoScriptUtility.php.txt index efc0e5a..f867cde 100644 --- a/Documentation/API/files/Classes/Utility/TypoScriptUtility.php.txt +++ b/Documentation/API/files/Classes/Utility/TypoScriptUtility.php.txt @@ -3,7 +3,7 @@ * Class TypoScriptUtility * * @author Robin 'codeFareith' von den Bergen - * @copyright (c) 2018-2019 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/Resources/Private/Templates/FrontendLogin/FrontendLogin.html b/Resources/Private/Templates/FeLogin/FrontendLogin.html similarity index 100% rename from Resources/Private/Templates/FrontendLogin/FrontendLogin.html rename to Resources/Private/Templates/FeLogin/FrontendLogin.html diff --git a/Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html b/Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html deleted file mode 100644 index b90d3f3..0000000 --- a/Resources/Private/Templates/FrontendLogin/Email/PasswordRecovery.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Resources/Private/Templates/FrontendLogin/Login/Login.html b/Resources/Private/Templates/FrontendLogin/Login/Login.html deleted file mode 100644 index 9660bff..0000000 --- a/Resources/Private/Templates/FrontendLogin/Login/Login.html +++ /dev/null @@ -1,92 +0,0 @@ - -
- -

- -

-
- - - - - - - - - - - -
-
- -
- - - - - - - - - - - - - - -
-
- - - - - - - - - - -
-
- - - - - - - -
-
- - -
- -
-
- - - - - - - - - - - -
-
-
- - - - -
-
-
- - \ No newline at end of file diff --git a/Resources/Private/Templates/FrontendLogin/Login/Logout.html b/Resources/Private/Templates/FrontendLogin/Login/Logout.html deleted file mode 100644 index ccb0649..0000000 --- a/Resources/Private/Templates/FrontendLogin/Login/Logout.html +++ /dev/null @@ -1,23 +0,0 @@ - - -
- - -
- - - - - - - - - - -
- diff --git a/Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html b/Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html deleted file mode 100644 index c9b94ac..0000000 --- a/Resources/Private/Templates/FrontendLogin/PasswordRecovery/Recovery.html +++ /dev/null @@ -1,21 +0,0 @@ - -
- -

-
- -
-
- -
- - -
- - - -
- -
-
- diff --git a/Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html b/Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html deleted file mode 100644 index 8833d61..0000000 --- a/Resources/Private/Templates/FrontendLogin/PasswordRecovery/ShowChangePassword.html +++ /dev/null @@ -1,30 +0,0 @@ - -
- -

-
- -
-
- -
- -
-
- - -
-
- - -
-

-

- - - -
- -
-
- diff --git a/Tests/Build/UnitTests.xml b/Tests/Build/UnitTests.xml index e63d396..02a8f4e 100644 --- a/Tests/Build/UnitTests.xml +++ b/Tests/Build/UnitTests.xml @@ -17,7 +17,6 @@ ../../Classes ../../Classes/Service/CoreAuthenticationServiceAdapter.php - ../../Classes/Service/LegacyAuthenticationServiceAdapter.php diff --git a/Tests/Unit/BaseTestCase.php b/Tests/Unit/BaseTestCase.php index 1d62655..a73d37f 100644 --- a/Tests/Unit/BaseTestCase.php +++ b/Tests/Unit/BaseTestCase.php @@ -1,7 +1,7 @@ - * @copyright (c) 2018 by Robin von den Bergen + * @copyright (c) 2018-2022 by Robin von den Bergen * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0.0 * diff --git a/composer.json b/composer.json index d38151e..3268d2d 100644 --- a/composer.json +++ b/composer.json @@ -46,16 +46,16 @@ "rss": "https://github.com/codeFareith/cf_google_authenticator/commits/master.atom" }, "require": { - "typo3/cms-core": "^8.7 || ^9.5 || ^10.4", - "typo3/cms-reports": "^8.7 || ^9.5 || ^10.4", - "typo3/cms-setup": "^8.7 || ^9.5 || ^10.4", + "typo3/cms-core": "^9.5 || ^10.4", + "typo3/cms-reports": "^9.5 || ^10.4", + "typo3/cms-setup": "^9.5 || ^10.4", "ext-json": "*" }, "require-dev": { "roave/security-advisories": "dev-master", - "typo3/testing-framework": "^2.0.1", + "typo3/testing-framework": "^3.4.2", "phpunit/php-code-coverage": "5.3.2", - "codeception/codeception": "^3.0" + "codeception/codeception": "^4.1" }, "conflict": {}, "replace": { @@ -66,6 +66,7 @@ "suggest": { "typo3/cms-felogin": "Needed to support 2FA for frontend accounts." }, + "autoload": { "psr-0": {}, "psr-4": { @@ -103,7 +104,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" }, "typo3/cms": { "extension-key": "cf_google_authenticator", @@ -115,4 +116,4 @@ "archive": {}, "abandoned": false, "non-feature-branches": [] -} \ No newline at end of file +} diff --git a/ext_conf_template.txt b/ext_conf_template.txt index c639892..f966c9d 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -6,10 +6,10 @@ googleAuthenticatorEnableBE = 1 # cat=basic/enable; type=boolean; label=LLL:EXT:cf_google_authenticator/Resources/Private/Language/locallang_ect.xlf:basic.googleAuthenticatorEnableFE -googleAuthenticatorEnableFE = 1 +googleAuthenticatorEnableFE = 0 # cat=basic/enable; type=string; label=LLL:EXT:cf_google_authenticator/Resources/Private/Language/locallang_ect.xlf:basic.feLoginTemplate -feLoginTemplate = EXT:cf_google_authenticator/Resources/Private/Templates/FrontendLogin/FrontendLogin.html +feLoginTemplate = EXT:cf_google_authenticator/Resources/Private/Templates/FeLogin/FrontendLogin.html # cat=basic/enable; type=boolean; label=LLL:EXT:cf_google_authenticator/Resources/Private/Language/locallang_ect.xlf:basic.devlog devlog = 0 diff --git a/ext_emconf.php b/ext_emconf.php index 82b9b72..15a33eb 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -1,59 +1,48 @@ - * @copyright (c) 2018-2019 by Robin von den Bergen - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - * @version 1.0.0 - * - * @link https://github.com/codeFareith/cf_google_authenticator - * @see https://www.fareith.de - * @see https://typo3.org - */ - -/** @var string $_EXTKEY */ + * Manual updates: + * Only the data in the array - everything else is removed by next + * writing. "version" and "dependencies" must not be touched! + ***************************************************************/ $EM_CONF[$_EXTKEY] = [ - 'title' => '[codeFareith] Google Authenticator', - 'description' => 'Enable Google 2FA (two factor authentication) for both, frontend- and backend accounts.', - 'category' => 'misc', - - 'author' => 'Robin "codeFareith" von den Bergen', - 'author_email' => 'robin@vondenbergen.de', - 'author_company' => '', - - 'state' => 'stable', - 'version' => '1.2.0', - - 'uploadFolders' => false, - 'createDirs' => '', - 'clearCacheOnLoad' => true, - - 'constraints' => [ - 'depends' => [ - 'php' => '7.4-', - 'typo3' => '8.7.0-10.4.99', + 'title' => '[codeFareith] Google Authenticator', + 'description' => 'Enable Google 2FA (two factor authentication) for both, frontend- and backend accounts.', + 'category' => 'misc', + 'author' => 'Robin "codeFareith" von den Bergen', + 'author_email' => 'robin@vondenbergen.de', + 'author_company' => '', + 'state' => 'stable', + 'version' => '1.2.4', + 'uploadFolders' => false, + 'createDirs' => '', + 'clearCacheOnLoad' => true, + 'constraints' => [ + 'depends' => [ + 'php' => '7.2-', + 'typo3' => '9.5.0-10.4.99', + ], + 'conflicts' => [ + ], + 'suggests' => [ + 'felogin' => '9.5.0-10.4.99', + ], ], - 'conflicts' => [], - 'suggests' => [ - 'felogin' => '8.7.0-10.4.99', - ], - ], - 'autoload' => [ - 'psr-4' => [ - 'CodeFareith\\CfGoogleAuthenticator\\' => 'Classes', + 'autoload' => [ + 'psr-4' => [ + 'CodeFareith\\CfGoogleAuthenticator\\' => 'Classes', + ], ], - ], - 'autoload-dev' => [ - 'psr-4' => [ - 'CodeFareith\\CfGoogleAuthenticator\\Tests\\' => 'Tests', + 'autoload-dev' => [ + 'psr-4' => [ + 'CodeFareith\\CfGoogleAuthenticator\\Tests\\' => 'Tests', + ], ], - ], ]; + diff --git a/ext_localconf.php b/ext_localconf.php index 0e80761..4c1db5f 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,5 +1,4 @@ createOneTimePasswordField'; + $globalsReference['TYPO3_CONF_VARS'] + ['EXTCONF'] + ['felogin'] + ['postProcContent'] + [$_EXTKEY] = \CodeFareith\CfGoogleAuthenticator\Hook\FeLogin::class . '->createOneTimePasswordField'; // Register a node in ext_localconf.php $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1606376982] = [ 'nodeName' => 'TwoFactorAuth', 'priority' => 40, - 'class' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettings::class, + 'class' => \CodeFareith\CfGoogleAuthenticator\Backend\Form\Element\TwoFactorAuth::class, ]; }, - /** @var string $_EXTKEY */ 'cf_google_authenticator' ); diff --git a/ext_tables.php b/ext_tables.php index 885f84f..da8daae 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,5 +1,4 @@ 'user', - 'userFunc' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettingsProfile::class . '->createSecretField', - 'table' => 'be_users', + 'userFunc' => \CodeFareith\CfGoogleAuthenticator\Hook\UserSettings::class . '->createSecretField', ], ] ); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings( '--div--;' - . \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( - 'tx_cfgoogleauthenticator', - 'locallang_db.xlf' - ) . ', + . \CodeFareith\CfGoogleAuthenticator\Utility\PathUtility::makeLocalLangLinkPath( + 'tx_cfgoogleauthenticator', + 'locallang_db.xlf' + ) . ', tx_cfgoogleauthenticator_enabled, tx_cfgoogleauthenticator_secret' ); }, - /** @var string $_EXTKEY */ 'cf_google_authenticator' ); diff --git a/ext_typoscript_setup.typoscript b/ext_typoscript_setup.typoscript deleted file mode 100644 index cec0503..0000000 --- a/ext_typoscript_setup.typoscript +++ /dev/null @@ -1,18 +0,0 @@ -config { - tx_extbase { - persistence { - classes { - CodeFareith\CfGoogleAuthenticator\Domain\Model\FrontendUser { - mapping { - tableName = fe_users - } - } - CodeFareith\CfGoogleAuthenticator\Domain\Model\BackendUser { - mapping { - tableName = be_users - } - } - } - } - } -} From 622a5de0076a21dd959746d3154a452096373389 Mon Sep 17 00:00:00 2001 From: Shaker Hasan Date: Wed, 9 Mar 2022 11:55:28 +0100 Subject: [PATCH 3/3] [TASK] Add French translations --- Resources/Private/Language/fr.locallang.xlf | 54 +++++++++++++++++ .../Private/Language/fr.locallang_be.xlf | 60 +++++++++++++++++++ .../Private/Language/fr.locallang_db.xlf | 31 ++++++++++ .../Private/Language/fr.locallang_ect.xlf | 26 ++++++++ 4 files changed, 171 insertions(+) create mode 100644 Resources/Private/Language/fr.locallang.xlf create mode 100644 Resources/Private/Language/fr.locallang_be.xlf create mode 100644 Resources/Private/Language/fr.locallang_db.xlf create mode 100644 Resources/Private/Language/fr.locallang_ect.xlf diff --git a/Resources/Private/Language/fr.locallang.xlf b/Resources/Private/Language/fr.locallang.xlf new file mode 100644 index 0000000..e719563 --- /dev/null +++ b/Resources/Private/Language/fr.locallang.xlf @@ -0,0 +1,54 @@ + + + +
+ + + Google Authenticator Code + + + + Configurer l'authentification à deux facteurs de Google + + + + Mot de passe unique + + + Pour désactiver Google Authenticator, saisissez le mot de passe à usage unique valide et cliquez sur le bouton DÉSACTIVER. + + + + Scannez le code QR + + + Scannez le code QR ci-dessous avec votre application Authenticator. + + + Conservez le code secret dans un endroit sûr + + + Vous avez besoin de ce code secret pour restaurer votre authentificateur. + + + Saisissez le code de vérification + + + Après avoir scanné le code QR, saisissez le code de vérification à 6 chiffres que votre application Authenticator a généré. + + + + Succès! + + + Vos modifications ont été enregistrées avec succès. + + + + diff --git a/Resources/Private/Language/fr.locallang_be.xlf b/Resources/Private/Language/fr.locallang_be.xlf new file mode 100644 index 0000000..e32f8ce --- /dev/null +++ b/Resources/Private/Language/fr.locallang_be.xlf @@ -0,0 +1,60 @@ + + + +
+ + + Google Authenticator QR-Code + + + + Clé + + + + Mot de passe unique + + + + Rangez cette clé dans un endroit sûr. + + + Vous aurez besoin de la clé si vous devez un jour restaurer l'Authenticator. + + + Pour désactiver Google Authenticator, décochez la case ci-dessus et saisissez un mot de passe à usage unique valide. + + + + Succès! + + + Votre compte est désormais également protégé par une authentification à deux facteurs. + + + Succès! + + + Vous avez désactivé l'authentification à deux facteurs. + + + Oops! + + + Le mot de passe à usage unique indiqué était incorrect ou a expiré. + + + Oops! + + + Le mot de passe à usage unique indiqué était incorrect ou a expiré. + + + + diff --git a/Resources/Private/Language/fr.locallang_db.xlf b/Resources/Private/Language/fr.locallang_db.xlf new file mode 100644 index 0000000..7ac6fcf --- /dev/null +++ b/Resources/Private/Language/fr.locallang_db.xlf @@ -0,0 +1,31 @@ + + + +
+ + + Google Authenticator + + + + Activer Google Authenticator + + + Clé de Google Authenticator + + + + Activer Google Authenticator + + + Clé de Google Authenticator + + + + diff --git a/Resources/Private/Language/fr.locallang_ect.xlf b/Resources/Private/Language/fr.locallang_ect.xlf new file mode 100644 index 0000000..59480f6 --- /dev/null +++ b/Resources/Private/Language/fr.locallang_ect.xlf @@ -0,0 +1,26 @@ + + + +
+ + + BE activé : Google Authenticator pour la connexion au backend est activé. + + + FE activé : Google Authenticator pour la connexion frontend est activé. + + + FE-Login Template File : si googleAuthenticatorEnableFE est défini et que vous utilisez EXT:felogin pour la connexion frontend de votre site, le modèle original "FrontendLogin.html" doit être remplacé par un modèle qui fournit le champ de mot de passe à usage unique. + + + Devlog : Écrire des informations de débog dans Devlog. + + + +