Skip to content

Commit 2941bf1

Browse files
committed
ACP2E-2755: Issue with rest api after enable 2FA Duo
1 parent 99f9bdb commit 2941bf1

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

TwoFactorAuth/Model/Provider/Engine/DuoSecurity.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ class DuoSecurity implements EngineInterface
7878
private $scopeConfig;
7979

8080
/**
81-
* @var bool
81+
* @var string
8282
*/
83-
private $forceUseDuoAuth;
83+
private $duoSignaturePrefix;
8484

8585
/**
8686
* @param ScopeConfigInterface $scopeConfig
87-
* @param bool $forceUseDuoAuth
87+
* @param string $duoSignaturePrefix
8888
*/
8989
public function __construct(
9090
ScopeConfigInterface $scopeConfig,
91-
bool $forceUseDuoAuth = false
91+
string $duoSignaturePrefix = self::AUTH_PREFIX
9292
) {
9393
$this->scopeConfig = $scopeConfig;
94-
$this->forceUseDuoAuth = $forceUseDuoAuth;
94+
$this->duoSignaturePrefix = $duoSignaturePrefix;
9595
}
9696

9797
/**
@@ -216,7 +216,7 @@ public function getRequestSignature(UserInterface $user): string
216216
$duoSignature = $this->signValues(
217217
$this->getSecretKey(),
218218
$values,
219-
$this->getPrefix(),
219+
$this->duoSignaturePrefix,
220220
static::DUO_EXPIRE,
221221
$time
222222
);
@@ -231,16 +231,6 @@ public function getRequestSignature(UserInterface $user): string
231231
return $duoSignature . ':' . $appSignature;
232232
}
233233

234-
/**
235-
* Return prefix to use in the signature
236-
*
237-
* @return string
238-
*/
239-
private function getPrefix() : string
240-
{
241-
return ($this->forceUseDuoAuth) ? static::DUO_PREFIX : static::AUTH_PREFIX;
242-
}
243-
244234
/**
245235
* @inheritDoc
246236
*/

TwoFactorAuth/Test/Unit/Model/Provider/Engine/DuoSecurityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function setUp(): void
4747
$this->user = $this->getMockBuilder(UserInterface::class)->disableOriginalConstructor()->getMock();
4848

4949
$this->model = $objectManager->getObject(DuoSecurity::class, ['scopeConfig' => $this->configMock]);
50-
$this->modelWithForcedDuoAuth = new DuoSecurity($this->configMock, true);
50+
$this->modelWithForcedDuoAuth = new DuoSecurity($this->configMock, $this->model::DUO_PREFIX);
5151
}
5252

5353
/**

TwoFactorAuth/etc/adminhtml/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</type>
2424
<type name="Magento\TwoFactorAuth\Model\Provider\Engine\DuoSecurity">
2525
<arguments>
26-
<argument name="forceUseDuoAuth" xsi:type="boolean">true</argument>
26+
<argument name="duoSignaturePrefix" xsi:type="const">Magento\TwoFactorAuth\Model\Provider\Engine\DuoSecurity::DUO_PREFIX</argument>
2727
</arguments>
2828
</type>
2929
</config>

0 commit comments

Comments
 (0)