Skip to content

Commit 32beaeb

Browse files
committed
CABPI-390: Do not allow to enable AdminAdobeIms when 2FA is disabled on IMS
1 parent f8224a7 commit 32beaeb

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

TwoFactorAuth/Observer/ControllerActionPredispatch.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
use Magento\Backend\App\AbstractAction;
1212
use Magento\Framework\App\Action\Action;
1313
use Magento\Framework\App\ActionFlag;
14-
use Magento\Framework\App\Config\ScopeConfigInterface;
1514
use Magento\Framework\AuthorizationInterface;
1615
use Magento\Framework\Event\Observer;
1716
use Magento\Framework\Event\ObserverInterface;
18-
use Magento\Framework\Module\Manager as ModuleManager;
1917
use Magento\Framework\UrlInterface;
2018
use Magento\TwoFactorAuth\Controller\Adminhtml\Tfa\Configure;
2119
use Magento\TwoFactorAuth\Controller\Adminhtml\Tfa\Index;
@@ -24,6 +22,7 @@
2422
use Magento\TwoFactorAuth\Api\UserConfigRequestManagerInterface;
2523
use Magento\TwoFactorAuth\Controller\Adminhtml\Tfa\Requestconfig;
2624
use Magento\TwoFactorAuth\Model\UserConfig\HtmlAreaTokenVerifier;
25+
use Magento\AdminAdobeIms\Service\ImsConfig;
2726

2827
/**
2928
* Handle redirection to 2FA page if required
@@ -76,14 +75,11 @@ class ControllerActionPredispatch implements ObserverInterface
7675
* @var UserContextInterface
7776
*/
7877
private $userContext;
78+
7979
/**
80-
* @var ModuleManager
81-
*/
82-
private $moduleManager;
83-
/**
84-
* @var ScopeConfigInterface
80+
* @var ImsConfig
8581
*/
86-
private $scopeConfig;
82+
private ImsConfig $adminAdobeImsConfig;
8783

8884
/**
8985
* @param TfaInterface $tfa
@@ -94,8 +90,7 @@ class ControllerActionPredispatch implements ObserverInterface
9490
* @param UrlInterface $url
9591
* @param AuthorizationInterface $authorization
9692
* @param UserContextInterface $userContext
97-
* @param ModuleManager $moduleManager
98-
* @param ScopeConfigInterface $scopeConfig
93+
* @param ImsConfig $adminAdobeImsConfig
9994
*/
10095
public function __construct(
10196
TfaInterface $tfa,
@@ -106,8 +101,7 @@ public function __construct(
106101
UrlInterface $url,
107102
AuthorizationInterface $authorization,
108103
UserContextInterface $userContext,
109-
ModuleManager $moduleManager,
110-
ScopeConfigInterface $scopeConfig
104+
ImsConfig $adminAdobeImsConfig
111105
) {
112106
$this->tfa = $tfa;
113107
$this->tfaSession = $tfaSession;
@@ -117,8 +111,7 @@ public function __construct(
117111
$this->url = $url;
118112
$this->authorization = $authorization;
119113
$this->userContext = $userContext;
120-
$this->moduleManager = $moduleManager;
121-
$this->scopeConfig = $scopeConfig;
114+
$this->adminAdobeImsConfig = $adminAdobeImsConfig;
122115
}
123116

124117
/**
@@ -138,8 +131,7 @@ private function redirect(string $url): void
138131
*/
139132
public function execute(Observer $observer)
140133
{
141-
if ($this->moduleManager->isEnabled('Magento_AdminAdobeIms')
142-
&& $this->scopeConfig->isSetFlag('adobe_ims/integration/adobe_ims_2fa_enabled')) {
134+
if ($this->adminAdobeImsConfig->enabled()) {
143135
return;
144136
}
145137
/** @var $controllerAction AbstractAction */

TwoFactorAuth/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"magento/module-ui": "*",
1313
"magento/module-user": "*",
1414
"magento/module-integration": "*",
15+
"magento/module-admin-adobe-ims": "*",
1516
"christian-riesen/base32": "^1.3",
1617
"spomky-labs/otphp": "^10.0",
1718
"endroid/qr-code": "^4.3.5",

TwoFactorAuth/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<sequence>
1212
<module name="Magento_User"/>
1313
<module name="Magento_Integration"/>
14+
<module name="Magento_AdminAdobeIms"/>
1415
</sequence>
1516
</module>
1617
</config>

0 commit comments

Comments
 (0)