Skip to content

Commit

Permalink
CABPI-390: Do not allow to enable AdminAdobeIms when 2FA is disabled …
Browse files Browse the repository at this point in the history
…on IMS
  • Loading branch information
slopukhov committed May 3, 2022
1 parent f8224a7 commit 32beaeb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
24 changes: 8 additions & 16 deletions TwoFactorAuth/Observer/ControllerActionPredispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
use Magento\Backend\App\AbstractAction;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\ActionFlag;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\Framework\UrlInterface;
use Magento\TwoFactorAuth\Controller\Adminhtml\Tfa\Configure;
use Magento\TwoFactorAuth\Controller\Adminhtml\Tfa\Index;
Expand All @@ -24,6 +22,7 @@
use Magento\TwoFactorAuth\Api\UserConfigRequestManagerInterface;
use Magento\TwoFactorAuth\Controller\Adminhtml\Tfa\Requestconfig;
use Magento\TwoFactorAuth\Model\UserConfig\HtmlAreaTokenVerifier;
use Magento\AdminAdobeIms\Service\ImsConfig;

/**
* Handle redirection to 2FA page if required
Expand Down Expand Up @@ -76,14 +75,11 @@ class ControllerActionPredispatch implements ObserverInterface
* @var UserContextInterface
*/
private $userContext;

/**
* @var ModuleManager
*/
private $moduleManager;
/**
* @var ScopeConfigInterface
* @var ImsConfig
*/
private $scopeConfig;
private ImsConfig $adminAdobeImsConfig;

/**
* @param TfaInterface $tfa
Expand All @@ -94,8 +90,7 @@ class ControllerActionPredispatch implements ObserverInterface
* @param UrlInterface $url
* @param AuthorizationInterface $authorization
* @param UserContextInterface $userContext
* @param ModuleManager $moduleManager
* @param ScopeConfigInterface $scopeConfig
* @param ImsConfig $adminAdobeImsConfig
*/
public function __construct(
TfaInterface $tfa,
Expand All @@ -106,8 +101,7 @@ public function __construct(
UrlInterface $url,
AuthorizationInterface $authorization,
UserContextInterface $userContext,
ModuleManager $moduleManager,
ScopeConfigInterface $scopeConfig
ImsConfig $adminAdobeImsConfig
) {
$this->tfa = $tfa;
$this->tfaSession = $tfaSession;
Expand All @@ -117,8 +111,7 @@ public function __construct(
$this->url = $url;
$this->authorization = $authorization;
$this->userContext = $userContext;
$this->moduleManager = $moduleManager;
$this->scopeConfig = $scopeConfig;
$this->adminAdobeImsConfig = $adminAdobeImsConfig;
}

/**
Expand All @@ -138,8 +131,7 @@ private function redirect(string $url): void
*/
public function execute(Observer $observer)
{
if ($this->moduleManager->isEnabled('Magento_AdminAdobeIms')
&& $this->scopeConfig->isSetFlag('adobe_ims/integration/adobe_ims_2fa_enabled')) {
if ($this->adminAdobeImsConfig->enabled()) {
return;
}
/** @var $controllerAction AbstractAction */
Expand Down
1 change: 1 addition & 0 deletions TwoFactorAuth/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"magento/module-ui": "*",
"magento/module-user": "*",
"magento/module-integration": "*",
"magento/module-admin-adobe-ims": "*",
"christian-riesen/base32": "^1.3",
"spomky-labs/otphp": "^10.0",
"endroid/qr-code": "^4.3.5",
Expand Down
1 change: 1 addition & 0 deletions TwoFactorAuth/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<sequence>
<module name="Magento_User"/>
<module name="Magento_Integration"/>
<module name="Magento_AdminAdobeIms"/>
</sequence>
</module>
</config>

0 comments on commit 32beaeb

Please sign in to comment.