Skip to content

Commit 180c646

Browse files
committed
AC-10982::[2FA] Integrate with Duo Web SDK to support Universal Prompt-fixes for static issues
1 parent 006ef91 commit 180c646

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

TwoFactorAuth/Model/Provider/Engine/DuoSecurity/Configure.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,15 @@ public function getConfigurationData(string $tfaToken)
6767

6868
/**
6969
* @inheritDoc
70-
* @throws \LocalizedException
7170
*/
7271
public function activate(string $tfaToken): void
7372
{
74-
try {
75-
$user = $this->userAuthenticator->authenticateWithTokenAndProvider($tfaToken, DuoSecurity::CODE);
76-
$userId = (int)$user->getId();
73+
$user = $this->userAuthenticator->authenticateWithTokenAndProvider($tfaToken, DuoSecurity::CODE);
74+
$userId = (int)$user->getId();
7775

78-
if ($this->duo->assertUserIsValid($user->getUserName()) == "auth") {
79-
$this->tfa->getProviderByCode(DuoSecurity::CODE)
80-
->activate($userId);
81-
}
82-
} catch (\Exception $e) {
83-
throw new \LocalizedException(__('Could not activate Duo Security provider.'));
76+
if ($this->duo->assertUserIsValid($user->getUserName()) == "auth") {
77+
$this->tfa->getProviderByCode(DuoSecurity::CODE)
78+
->activate($userId);
8479
}
8580
}
8681
}

TwoFactorAuth/Test/Integration/Model/Provider/Engine/DuoSecurity/ConfigureTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,12 @@ public function testActivateInvalidDataThrowsException()
269269
$userId = $this->getUserId();
270270
$tfat = $this->tokenManager->issueFor($userId);
271271

272-
$this->duo->method('assertUserIsValid')
273-
->with($this->callback(function ($username) use ($userId) {
274-
// Assuming $username corresponds to a user object or username string.
275-
// Replace 'getUserById' with the relevant logic for obtaining the username
276-
$user = $this->userFactory->create()->load($userId);
277-
return $username === $user->getUserName();
278-
}))
272+
$userName = 'adminUser';
273+
274+
$this->duo
275+
->expects($this->once())
276+
->method('assertUserIsValid')
277+
->with($userName)
279278
->willThrowException(new \InvalidArgumentException('Something'));
280279

281280
// Call activate without a signature, as per your updated logic

0 commit comments

Comments
 (0)