Skip to content

Commit 361792d

Browse files
authored
Merge pull request #40 from magento-commerce/imported-magento-security-package-297
MC-42905: Unable to Plugin to \Magento\TwoFactorAuth\Observer\ControllerActionPredispatch
2 parents 8d5c176 + fc2f09a commit 361792d

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

TwoFactorAuth/TestFramework/ControllerActionPredispatch.php renamed to TwoFactorAuth/TestFramework/Plugin/BypassTwoFactorAuth.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,34 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\TwoFactorAuth\TestFramework;
9+
namespace Magento\TwoFactorAuth\TestFramework\Plugin;
1010

11+
use Closure;
1112
use Magento\Backend\App\AbstractAction;
1213
use Magento\Framework\Event\Observer;
13-
use Magento\TwoFactorAuth\Observer\ControllerActionPredispatch as ParentObserver;
14+
use Magento\TestFramework\Request;
15+
use Magento\TwoFactorAuth\Observer\ControllerActionPredispatch;
1416

1517
/**
16-
* Observer that allows integration controller tests that are not aware of 2FA to run.
18+
* Plugin that allows integration controller tests that are not aware of 2FA to run.
1719
*/
18-
class ControllerActionPredispatch extends ParentObserver
20+
class BypassTwoFactorAuth
1921
{
20-
/**
21-
* @inheritDoc
22-
*/
23-
public function execute(Observer $observer)
24-
{
22+
public function aroundExecute(
23+
ControllerActionPredispatch $subject,
24+
Closure $proceed,
25+
Observer $observer
26+
) : void {
2527
/** @var $controllerAction AbstractAction */
2628
$controllerAction = $observer->getEvent()->getData('controller_action');
2729
if (method_exists($controllerAction, 'getRequest')
28-
&& $controllerAction->getRequest() instanceof \Magento\TestFramework\Request
30+
&& $controllerAction->getRequest() instanceof Request
2931
&& !$controllerAction->getRequest()->getParam('tfa_enabled')
3032
) {
3133
//Hack that allows integration controller tests that are not aware of 2FA to run
3234
return;
3335
}
3436

35-
parent::execute($observer);
37+
$proceed($observer);
3638
}
3739
}

TwoFactorAuth/etc/di.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
<preference for="Magento\TwoFactorAuth\Api\DuoAuthenticateInterface" type="Magento\TwoFactorAuth\Model\Provider\Engine\DuoSecurity\Authenticate"/>
4141
<preference for="Magento\TwoFactorAuth\Api\Data\DuoDataInterface" type="Magento\TwoFactorAuth\Model\Data\Provider\Engine\DuoSecurity\Data"/>
4242
<preference for="Magento\TwoFactorAuth\Api\U2fKeyConfigReaderInterface" type="Magento\TwoFactorAuth\Model\Provider\Engine\U2fKey\ConfigReader"/>
43-
<preference for="OTPHP\TOTPInterface" type="OTPHP\TOTP"/>
4443

4544
<type name="Magento\Framework\Console\CommandListInterface">
4645
<arguments>
@@ -87,6 +86,10 @@
8786
<plugin name="fixDefaultUrl" type="Magento\TwoFactorAuth\Plugin\FirstAvailableMenu"/>
8887
</type>
8988

89+
<type name="Magento\TwoFactorAuth\Observer\ControllerActionPredispatch">
90+
<plugin name="bypass_twofactorauth_testframework" type="Magento\TwoFactorAuth\TestFramework\Plugin\BypassTwoFactorAuth" />
91+
</type>
92+
9093
<virtualType name="Magento\TwoFactorAuth\Model\Provider\Google" type="Magento\TwoFactorAuth\Model\Provider">
9194
<arguments>
9295
<argument name="engine" xsi:type="object">Magento\TwoFactorAuth\Model\Provider\Engine\Google</argument>
@@ -159,5 +162,4 @@
159162
<preference for="Magento\TwoFactorAuth\Api\UserConfigRequestManagerInterface" type="Magento\TwoFactorAuth\Model\UserConfig\UserConfigRequestManager" />
160163
<preference for="Magento\TwoFactorAuth\Api\UserConfigTokenManagerInterface" type="Magento\TwoFactorAuth\Model\UserConfig\SignedTokenManager" />
161164
<preference for="Magento\TwoFactorAuth\Api\UserNotifierInterface" type="Magento\TwoFactorAuth\Model\EmailUserNotifier" />
162-
<preference for="Magento\TwoFactorAuth\Observer\ControllerActionPredispatch" type="Magento\TwoFactorAuth\TestFramework\ControllerActionPredispatch" />
163165
</config>

0 commit comments

Comments
 (0)