Skip to content

Commit 0dfdb24

Browse files
committed
AC-10982::[2FA] Integrate with Duo Web SDK to support Universal Prompt-unit tests fixes
1 parent 59b8ebf commit 0dfdb24

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

TwoFactorAuth/Model/Provider/Engine/DuoSecurity.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Framework\DataObject;
1313
use Magento\Framework\Data\Form\FormKey;
1414
use Magento\Framework\Encryption\EncryptorInterface;
15-
use Magento\Framework\Session\SessionManagerInterface;
1615
use Magento\Framework\UrlInterface;
1716
use Magento\User\Api\Data\UserInterface;
1817
use Magento\TwoFactorAuth\Api\EngineInterface;
@@ -21,7 +20,6 @@
2120

2221
/**
2322
* Duo Security engine
24-
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2523
*/
2624
class DuoSecurity implements EngineInterface
2725
{
@@ -110,17 +108,11 @@ class DuoSecurity implements EngineInterface
110108
*/
111109
private $formKey;
112110

113-
/**
114-
* @var SessionManagerInterface
115-
*/
116-
private $session;
117-
118111
/**
119112
* @param ScopeConfigInterface $scopeConfig
120113
* @param EncryptorInterface $encryptor
121114
* @param UrlInterface $urlBuilder
122115
* @param FormKey $formKey
123-
* @param SessionManagerInterface $session
124116
* @param Client|null $client
125117
* @param DuoAuth|null $duoAuth
126118
* @throws \Duo\DuoUniversal\DuoException
@@ -130,15 +122,13 @@ public function __construct(
130122
EncryptorInterface $encryptor,
131123
UrlInterface $urlBuilder,
132124
FormKey $formKey,
133-
SessionManagerInterface $session,
134125
Client $client = null,
135126
DuoAuth $duoAuth = null
136127
) {
137128
$this->scopeConfig = $scopeConfig;
138129
$this->encryptor = $encryptor;
139130
$this->urlBuilder = $urlBuilder;
140131
$this->formKey = $formKey;
141-
$this->session = $session;
142132
$this->client = $client ?? new Client(
143133
$this->getClientId(),
144134
$this->getClientSecret(),
@@ -239,9 +229,8 @@ public function verify(UserInterface $user, DataObject $request): bool
239229
}
240230

241231
try {
232+
// Not saving token as this is just for verificaiton purpose
242233
$decoded_token = $this->client->exchangeAuthorizationCodeFor2FAResult($duoCode, $username);
243-
// Save the token in the session for later use
244-
$this->session->setData('duo_token', $decoded_token);
245234
} catch (LocalizedException $e) {
246235
return false;
247236
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Framework\Data\Form\FormKey;
1313
use Magento\Framework\DataObject;
1414
use Magento\Framework\Encryption\EncryptorInterface;
15-
use Magento\Framework\Session\SessionManagerInterface;
1615
use Magento\Framework\UrlInterface;
1716
use Magento\TwoFactorAuth\Model\Provider\Engine\DuoSecurity;
1817
use Magento\User\Api\Data\UserInterface;
@@ -35,9 +34,6 @@ class DuoSecurityTest extends TestCase
3534
/** @var MockObject|FormKey */
3635
private $formKeyMock;
3736

38-
/** @var MockObject|SessionManagerInterface */
39-
private $sessionMock;
40-
4137
/** @var MockObject|Client */
4238
private $clientMock;
4339

@@ -67,10 +63,6 @@ protected function setUp(): void
6763
->disableOriginalConstructor()
6864
->getMock();
6965

70-
$this->sessionMock = $this->getMockBuilder(SessionManagerInterface::class)
71-
->disableOriginalConstructor()
72-
->getMock();
73-
7466
$this->clientMock = $this->createMock(Client::class);
7567
$this->duoAuthMock = $this->createMock(DuoAuth::class);
7668

@@ -79,7 +71,6 @@ protected function setUp(): void
7971
$this->encryptorMock,
8072
$this->urlMock,
8173
$this->formKeyMock,
82-
$this->sessionMock,
8374
$this->clientMock,
8475
$this->duoAuthMock
8576
);

0 commit comments

Comments
 (0)