-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright © 2020-present Wolfsellers | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace WolfSellers\EnableDisableTfa\Model; | ||
|
||
use Magento\TwoFactorAuth\TestFramework\ControllerActionPredispatch as MagentoControllerActionPredispatch; | ||
|
||
class ControllerActionPredispatch extends MagentoControllerActionPredispatch | ||
{ | ||
} |
45 changes: 45 additions & 0 deletions
45
Plugin/Backend/Magento/TwoFactorAuth/Observer/ControllerActionPredispatch.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Copyright © Wolfsellers All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace WolfSellers\EnableDisableTfa\Plugin\Backend\Magento\TwoFactorAuth\Observer; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\TwoFactorAuth\Observer\ControllerActionPredispatch as MagentoControllerActionPredispatch; | ||
|
||
class ControllerActionPredispatch | ||
{ | ||
const TWOFACTOR_AUTH_ENABLED = "twofactorauth/general/enabled"; | ||
|
||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
|
||
/** | ||
* ControllerActionPredispatch constructor. | ||
* @param ScopeConfigInterface $scopeConfig | ||
* @param \Psr\Log\LoggerInterface $logger | ||
*/ | ||
public function __construct( | ||
ScopeConfigInterface $scopeConfig | ||
) { | ||
|
||
$this->scopeConfig = $scopeConfig; | ||
} | ||
|
||
public function aroundExecute( | ||
MagentoControllerActionPredispatch $subject, | ||
callable $proceed, | ||
Observer $observer | ||
) { | ||
if($this->scopeConfig->isSetFlag(self::TWOFACTOR_AUTH_ENABLED)) { | ||
$proceed($observer); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Magento 2 Module WolfSellers Enable Disable 2FA | ||
|
||
- [Main Functionalities](#markdown-header-main-functionalities) | ||
- [Installation](#markdown-header-installation) | ||
- [Tested](#markdown-header-tested) | ||
|
||
|
||
## Main Functionalities | ||
Adds enable disable feature switch for the Two-factor Authorization for Magento 2.4 | ||
|
||
It can be configured in `Stores > Configuration > 2FA > General > Enabled` by default is set to no, so the admin can be used. | ||
Change it back in production. | ||
|
||
## Installation | ||
|
||
### 1. Composer (recommended) | ||
|
||
- Install the module composer by running `composer require wolfsellers/module-enabledisabletfa` | ||
- Enable the module by running `php bin/magento module:enable WolfSellers_EnableDisableTfa` | ||
- Apply database updates by running `php bin/magento setup:upgrade` | ||
- Flush the cache by running `php bin/magento cache:flush` | ||
|
||
### 2. Download zip (not recommended) | ||
|
||
- Download the zip file from github | ||
- Extract the files in `app/code/WolfSellers/EnableDisableTfa/` | ||
- Enable the module by running `php bin/magento module:enable WolfSellers_EnableDisableTfa` | ||
- Apply database updates by running `php bin/magento setup:upgrade` | ||
- Flush the cache by running `php bin/magento cache:flush` | ||
|
||
## Tested | ||
|
||
Tested in Magento 2.4.0, versions: | ||
- Community | ||
- Enterprise | ||
- Cloud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "wolfsellers/module-enabledisabletfa", | ||
"description": "Adds enable disable switch for the Two-factor Authorization", | ||
"type": "magento2-module", | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"authors": [ | ||
{ | ||
"name": "Rus0", | ||
"email": "[email protected]", | ||
"homepage": "https://wolfsellers.com" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"magento/module-two-factor-auth": "^1.0.*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"WolfSellers\\EnableDisableTfa\\": "" | ||
}, | ||
"files": [ | ||
"registration.php" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" ?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\TwoFactorAuth\Observer\ControllerActionPredispatch"> | ||
<plugin name="WolfSellers_EnableDisableTfa_Plugin_Backend_Magento_TwoFactorAuth_Observer_ControllerActionPredispatch" | ||
disabled="false" sortOrder="0" | ||
type="WolfSellers\EnableDisableTfa\Plugin\Backend\Magento\TwoFactorAuth\Observer\ControllerActionPredispatch"/> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" ?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> | ||
<system> | ||
<section id="twofactorauth"> | ||
<tab>security</tab> | ||
<resource>Magento_TwoFactorAuth::config</resource> | ||
<group id="general"> | ||
<field id="enabled" showInDefault="1" showInStore="0" showInWebsite="0" sortOrder="0" translate="label" type="select"> | ||
<label>Enabled</label> | ||
<comment>Enables/Disables Two-factor authorization</comment> | ||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> | ||
</field> | ||
</group> | ||
</section> | ||
</system> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" ?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> | ||
<default> | ||
<twofactorauth> | ||
<general> | ||
<enabled>0</enabled> | ||
</general> | ||
</twofactorauth> | ||
</default> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" ?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<preference for="Magento\TwoFactorAuth\TestFramework\ControllerActionPredispatch" type="WolfSellers\EnableDisableTfa\Model\ControllerActionPredispatch" /> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" ?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="WolfSellers_EnableDisableTfa"> | ||
<sequence> | ||
<module name="Magento_TwoFactorAuth"/> | ||
</sequence> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/** | ||
* Copyright © Wolfsellers All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'WolfSellers_EnableDisableTfa', __DIR__); | ||
|