Skip to content

Commit f57d3a8

Browse files
committed
AC-10982::[2FA] Integrate with Duo Web SDK to support Universal Prompt-WebSdk login prompt related changes
1 parent c4d1313 commit f57d3a8

File tree

7 files changed

+32
-48
lines changed

7 files changed

+32
-48
lines changed

TwoFactorAuth/Block/Provider/Duo/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getJsLayout()
8282
}
8383
$username = $user->getUserName();
8484
$prompt_uri = $this->duoSecurity->initiateAuth($username, $this->getFormKey().DuoSecurity::AUTH_SUFFIX);
85-
$this->jsLayout['components']['tfa-auth']['redirectUrl'] = $prompt_uri;
85+
$this->jsLayout['components']['tfa-auth']['authUrl'] = $prompt_uri;
8686
return parent::getJsLayout();
8787
}
8888
}

TwoFactorAuth/Model/Provider/Engine/DuoSecurity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public function verify(UserInterface $user, DataObject $request): bool
241241
try {
242242
$decoded_token = $this->client->exchangeAuthorizationCodeFor2FAResult($duoCode, $username);
243243
// Save the token in the session for later use
244-
$this->session->duo_token = $decoded_token;
244+
$this->session->setData('duo_token', $decoded_token);
245245
} catch (LocalizedException $e) {
246246
return false;
247247
}

TwoFactorAuth/Test/Integration/Controller/Adminhtml/Duo/AuthpostTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
class AuthpostTest extends AbstractConfigureBackendController
2121
{
2222
/**
23-
* @inheritDoc
23+
* @var string
2424
*/
2525
protected $uri = 'backend/tfa/duo/authpost';
2626

2727
/**
28-
* @inheritDoc
28+
* @var string
2929
*/
3030
protected $httpMethod = Request::METHOD_GET;
3131

TwoFactorAuth/view/adminhtml/templates/tfa/provider/auth.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright 2024 Adobe
4-
* All Rights Reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
55
*/
66
?>
77
<div id="tfa-auth-container" data-bind="scope:'tfa-auth'">
@@ -13,7 +13,7 @@
1313
<script type="text/x-magento-init">
1414
{
1515
"#tfa-auth-container": {
16-
"Magento_TwoFactorAuth/js/duo/api": <?= /* @noEscape */ $block->getJsLayout() ?>
16+
"Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
1717
}
1818
}
1919
</script>

TwoFactorAuth/view/adminhtml/web/js/duo/api.js

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2024 Adobe
3+
* All Rights Reserved.
44
*/
55

66
define([
77
'ko',
8-
'uiComponent',
9-
'Magento_TwoFactorAuth/js/duo/api'
10-
], function (ko, Component, duo) {
8+
'uiComponent'
9+
], function (ko, Component) {
1110
'use strict';
1211

1312
return Component.extend({
@@ -17,16 +16,24 @@ define([
1716
template: 'Magento_TwoFactorAuth/duo/auth'
1817
},
1918

20-
redirectUrl: '',
21-
authenticateData: {},
19+
authUrl: '',
20+
21+
getAuthUrl: function () {
22+
return this.authUrl;
23+
},
24+
25+
redirectToAuthUrl: function () {
26+
var redirectUrl = this.getAuthUrl();
27+
if (redirectUrl) {
28+
window.location.href = redirectUrl;
29+
}
30+
},
2231

2332
/**
24-
* Start waiting loop
33+
* After the element is rendered, bind the authUrl (optional)
2534
*/
2635
onAfterRender: function () {
27-
window.setTimeout(function () {
28-
duo(this, null);
29-
}, 1000);
30-
},
36+
var authUrl = this.getAuthUrl();
37+
}
3138
});
3239
});
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
<!--
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
-->
77
<div>
88
<form>
99
<fieldset class="admin__fieldset">
1010
<legend class="admin__legend"><span translate="'2FA - Duo Security'"></span></legend>
1111
<br/>
12-
13-
<iframe id="duo_iframe"
14-
data-bind="afterRender: onAfterRender"
15-
attr="{
16-
'data-host': getApiHost(),
17-
'data-sig-request': getSignature(),
18-
'data-post-action': getPostUrl()
19-
}"
20-
></iframe>
12+
<button type="button" data-bind="click: redirectToAuthUrl, afterRender: onAfterRender">
13+
Go to Duo Universal Prompt
14+
</button>
2115
</fieldset>
2216
</form>
2317
</div>
18+

0 commit comments

Comments
 (0)