Skip to content

Commit 23ed204

Browse files
committed
MC-22950: Enable 2FA by default for Admins
- More compatibility changes - UI/UX enhancements
1 parent 0900b6a commit 23ed204

File tree

6 files changed

+33
-11
lines changed

6 files changed

+33
-11
lines changed

TwoFactorAuth/Model/Provider/Engine/U2fKey/WebAuthn.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ public function getPublicKeyFromRegistrationData(array $data): array
223223
$attestationObject = CBOREncoder::decode($byteString);
224224
if (empty($attestationObject['fmt'])
225225
|| empty($attestationObject['authData'])
226-
|| $attestationObject['fmt'] === 'fido-u2f'
227-
|| $attestationObject['fmt'] !== 'none' && $attestationObject['fmt'] !== 'packed'
228226
) {
229227
throw new ValidationException(__('Invalid U2F key data'));
230228
}
@@ -240,8 +238,8 @@ public function getPublicKeyFromRegistrationData(array $data): array
240238
throw new ValidationException(__('Invalid U2F key data'));
241239
}
242240

243-
// User presence, attestation data, user verified
244-
if (!($attestationObject['flags'] & 0b1000011)) {
241+
// User presence, attestation data
242+
if (!($attestationObject['flags'] & 0b1000001)) {
245243
throw new ValidationException(__('Invalid U2F key data'));
246244
}
247245

@@ -266,7 +264,8 @@ public function getPublicKeyFromRegistrationData(array $data): array
266264

267265
return [
268266
'key' => $attestationObject['attestationData']['keyBytes'],
269-
'id' => $data['id']
267+
'id' => $data['id'],
268+
'aaguid' => $attestationObject['attestationData']['aaguid'] ?? null
270269
];
271270
}
272271

TwoFactorAuth/view/adminhtml/web/css/u2f.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ fieldset {
77
text-align: center;
88
}
99

10-
.tfa-u2f-touch-key {
11-
margin-bottom: 1em;
12-
}
13-
10+
.tfa-u2f-touch-key,
1411
.tfa-u2f-try-again {
1512
margin-bottom: 1em;
1613
}

TwoFactorAuth/view/adminhtml/web/js/u2fkey/auth.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ define([
1818

1919
defaults: {
2020
template: 'Magento_TwoFactorAuth/u2fkey/auth',
21-
idle: ko.observable(true)
21+
idle: ko.observable(true),
22+
loading: ko.observable(false)
2223
},
2324

2425
postUrl: '',
@@ -113,6 +114,7 @@ define([
113114
* @private
114115
*/
115116
_processCredentialData: function (credentialData) {
117+
this.loading(true);
116118
$.post(this.getPostUrl(), {
117119
publicKeyCredential: {
118120
type: credentialData.type,
@@ -126,6 +128,8 @@ define([
126128
}
127129
})
128130
.done(function (res) {
131+
this.loading(false);
132+
129133
if (res.success) {
130134
this.currentStep('login');
131135
self.location.href = this.getSuccessUrl();
@@ -136,6 +140,7 @@ define([
136140
}.bind(this))
137141
.fail(function () {
138142
error.display($t('Invalid key or key is not registered.'));
143+
this.loading(false);
139144
this.idle(true);
140145
}.bind(this));
141146
},

TwoFactorAuth/view/adminhtml/web/js/u2fkey/configure.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ define([
1818

1919
defaults: {
2020
template: 'Magento_TwoFactorAuth/u2fkey/configure',
21-
idle: ko.observable(true)
21+
idle: ko.observable(true),
22+
loading: ko.observable(false)
2223
},
2324

2425
postUrl: '',
@@ -125,6 +126,7 @@ define([
125126
return;
126127
}
127128

129+
this.loading(true);
128130
$.post(this.getPostUrl(), {
129131
publicKeyCredential: {
130132
id: utils.arrayBufferToBase64(credentialData.rawId),
@@ -137,6 +139,8 @@ define([
137139
}
138140
})
139141
.done(function (res) {
142+
this.loading(false);
143+
140144
if (res.success) {
141145
this.currentStep('login');
142146
self.location.href = this.getSuccessUrl();
@@ -147,6 +151,7 @@ define([
147151
}.bind(this))
148152
.fail(function () {
149153
error.display($t('Unable to register your device'));
154+
this.loading(false);
150155
this.idle(true);
151156
}.bind(this));
152157
},

TwoFactorAuth/view/adminhtml/web/template/u2fkey/auth.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ <h3 translate="'Plug in your U2F key and follow instructions'"></h3>
2727
</div>
2828
<div translate="'Redirecting to Magento Admin Panel...'"></div>
2929
</div>
30+
<div visible='$data.loading' class="tfa-waitbox">
31+
<div data-role="spinner">
32+
<div class="spinner">
33+
<span/><span/><span/><span/><span/><span/><span/><span/>
34+
</div>
35+
</div>
36+
<div translate="'Loading...'"></div>
37+
</div>
3038
</div>

TwoFactorAuth/view/adminhtml/web/template/u2fkey/configure.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ <h3 translate="'Plug in your U2F key and follow instructions'"></h3>
2727
</div>
2828
<div translate="'Redirecting to Magento Admin Panel...'"></div>
2929
</div>
30+
<div visible='$data.loading' class="tfa-waitbox">
31+
<div data-role="spinner">
32+
<div class="spinner">
33+
<span/><span/><span/><span/><span/><span/><span/><span/>
34+
</div>
35+
</div>
36+
<div translate="'Loading...'"></div>
37+
</div>
3038
</div>

0 commit comments

Comments
 (0)