File tree Expand file tree Collapse file tree 7 files changed +15
-72
lines changed
Test/Integration/Controller/Adminhtml/Duo Expand file tree Collapse file tree 7 files changed +15
-72
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ protected function _getElementHtml(AbstractElement $element)
53
53
'twofactorauth_duo_client_id ' ,
54
54
'twofactorauth_duo_client_secret ' ,
55
55
'twofactorauth_duo_api_hostname ' ,
56
- 'twofactorauth_duo_failmode ' ,
57
56
'twofactorauth_duo_integration_key ' ,
58
57
'twofactorauth_duo_secret_key ' ,
59
58
]
Original file line number Diff line number Diff line change 11
11
use Magento \Backend \Block \Template ;
12
12
use Magento \Backend \Model \Auth \Session ;
13
13
use Magento \Framework \Exception \LocalizedException ;
14
+ use Magento \TwoFactorAuth \Model \Provider \Engine \DuoSecurity ;
14
15
15
16
/**
16
17
* @api
17
18
*/
18
19
class Auth extends Template
19
20
{
21
+ /**
22
+ * @var DuoSecurity
23
+ */
24
+ private $ duoSecurity ;
25
+
20
26
/**
21
27
* @var Session
22
28
*/
@@ -25,14 +31,17 @@ class Auth extends Template
25
31
/**
26
32
* @param Template\Context $context
27
33
* @param Session $session
34
+ * @param DuoSecurity $duoSecurity
28
35
* @param array $data
29
36
*/
30
37
public function __construct (
31
38
Template \Context $ context ,
32
39
Session $ session ,
40
+ DuoSecurity $ duoSecurity ,
33
41
array $ data = []
34
42
) {
35
43
parent ::__construct ($ context , $ data );
44
+ $ this ->duoSecurity = $ duoSecurity ;
36
45
$ this ->session = $ session ;
37
46
}
38
47
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2020 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
+
6
7
declare (strict_types=1 );
7
8
8
9
namespace Magento \TwoFactorAuth \Controller \Adminhtml \Duo ;
@@ -117,12 +118,8 @@ public function execute()
117
118
$ state = $ this ->duoSecurity ->generateDuoState ();
118
119
$ this ->session ->setDuoState ($ state );
119
120
$ response = $ this ->duoSecurity ->initiateAuth ($ username , $ state );
120
- if ($ response ['status ' ] === 'open ' ) {
121
- // If fail mode is "open", skip the Duo prompt.
122
- $ this ->messageManager ->addErrorMessage ($ response ['message ' ]);
123
- }
124
- if ($ response ['status ' ] === 'closed ' ) {
125
- // If fail mode is "closed", show an error message.
121
+ if ($ response ['status ' ] === 'failure ' ) {
122
+ // if health check fails, skip the Duo prompt and choose different 2FA.
126
123
$ this ->messageManager ->addErrorMessage ($ response ['message ' ]);
127
124
}
128
125
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -57,11 +57,6 @@ class DuoSecurity implements EngineInterface
57
57
*/
58
58
public const XML_PATH_SKEY = 'twofactorauth/duo/secret_key ' ;
59
59
60
- /**
61
- * Configuration path for Duo Mode
62
- */
63
- public const DUO_FAILMODE = 'twofactorauth/duo/duo_failmode ' ;
64
-
65
60
/**
66
61
* @var ScopeConfigInterface
67
62
*/
@@ -142,16 +137,6 @@ private function getClientId(): string
142
137
return $ this ->scopeConfig ->getValue (static ::XML_PATH_CLIENT_ID );
143
138
}
144
139
145
- /**
146
- * Get Duo Mode
147
- *
148
- * @return string
149
- */
150
- public function getDuoFailmode (): string
151
- {
152
- return strtoupper ($ this ->scopeConfig ->getValue (static ::DUO_FAILMODE ));
153
- }
154
-
155
140
/**
156
141
* Get callback URL
157
142
*
@@ -241,27 +226,14 @@ public function isEnabled(): bool
241
226
*/
242
227
public function initiateAuth ($ username , string $ state ): array
243
228
{
244
- $ duoFailMode = $ this ->getDuoFailmode ();
245
229
try {
246
230
$ this ->healthCheck ();
247
231
} catch (DuoException $ e ) {
248
- if ($ duoFailMode === "OPEN " ) {
249
- return [
250
- 'status ' => 'open ' ,
251
- 'redirect_url ' => '' ,
252
- 'message ' => __ (
253
- "Login 'applicable',
254
- but 2FA Not Performed. Switch to other 2FA Provider.
255
- Confirm Duo client/secret/host values are correct "
256
- )
257
- ];
258
- } else {
259
232
return [
260
- 'status ' => 'closed ' ,
233
+ 'status ' => 'failure ' ,
261
234
'redirect_url ' => '' ,
262
235
'message ' => __ ("2FA Unavailable. Confirm Duo client/secret/host values are correct " )
263
236
];
264
- }
265
237
}
266
238
267
239
return [
Original file line number Diff line number Diff line change @@ -52,7 +52,6 @@ public function testTokenAccess(): void
52
52
* @magentoConfigFixture default/twofactorauth/duo/integration_key abc123
53
53
* @magentoConfigFixture default/twofactorauth/duo/api_hostname test.duosecurity.com
54
54
* @magentoConfigFixture default/twofactorauth/duo/secret_key abc123
55
- * @magentoConfigFixture default/twofactorauth/duo/duo_failmode open
56
55
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
57
56
*/
58
57
public function testAclHasAccess ()
@@ -68,7 +67,6 @@ public function testAclHasAccess()
68
67
* @magentoConfigFixture default/twofactorauth/duo/integration_key abc123
69
68
* @magentoConfigFixture default/twofactorauth/duo/api_hostname test.duosecurity.com
70
69
* @magentoConfigFixture default/twofactorauth/duo/secret_key abc123
71
- * @magentoConfigFixture default/twofactorauth/duo/duo_failmode open
72
70
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
73
71
*/
74
72
public function testAclNoAccess ()
Original file line number Diff line number Diff line change 78
78
<label >API hostname</label >
79
79
<backend_model >Magento\TwoFactorAuth\Model\Config\Backend\Duo\ApiHostname</backend_model >
80
80
</field >
81
- <field id =" duo_failmode" translate =" label comment" type =" select" sortOrder =" 50" showInDefault =" 1"
82
- showInWebsite =" 0" showInStore =" 0" >
83
- <label >Duo Failmode</label >
84
- <source_model >Magento\TwoFactorAuth\Model\Config\Source\DuoFailmode</source_model >
85
- </field >
86
81
<field id =" integration_key" translate =" label comment" type =" text" sortOrder =" 60" showInDefault =" 1"
87
82
showInWebsite =" 0" showInStore =" 0" >
88
83
<label >Integration Key</label >
You can’t perform that action at this time.
0 commit comments