Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

Commit 6af823c

Browse files
author
Billy Clark
committed
only certain browsers support u2f
1 parent f99a753 commit 6af823c

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

dictionaries/mfa.definition.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@
7878
"fr": "TODO",
7979
"ko": "TODO"
8080
},
81+
"u2f_unsupported": {
82+
"en": "Unsupported in your current browser. Please consider a more secure browser like <a href='https://www.google.com/chrome/browser' target='_blank'>Google Chrome</a>.",
83+
"es": "TODO",
84+
"fr": "TODO",
85+
"ko": "TODO"
86+
},
8187
"shield_icon": {
8288
"en": "Shield icon",
8389
"es": "TODO",

themes/material/mfa/prompt-for-mfa-u2f.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,23 @@
66
<?php include __DIR__ . '/../common-head-elements.php' ?>
77

88
<script src="mfa-u2f-api.js"></script>
9+
<script src="bowser.1.8.0.min.js"></script>
10+
911
<script>
12+
function isU2fSupported() {
13+
var isSupported = (bowser.chrome && bowser.version >= 41) ||
14+
(bowser.firefox && bowser.version >= 58) ||
15+
(bowser.opera && bowser.version >= 39);
16+
17+
var nodeToShow = isSupported ? document.querySelector('#supported') :
18+
document.querySelector('#unsupported');
19+
20+
nodeToShow.classList.remove('hide');
21+
22+
return isSupported;
23+
}
24+
1025
function verifyU2f() {
11-
// TODO: need feature sniff and error handling
1226
var u2fSignRequest = <?= json_encode($this->data['mfaOption']['data']) ?> || {};
1327

1428
u2f.sign(u2fSignRequest.appId, u2fSignRequest.challenge, [u2fSignRequest],
@@ -65,7 +79,7 @@ function createHiddenInput(name) {
6579
}
6680
</script>
6781
</head>
68-
<body class="gradient-bg" onload="verifyU2f()">
82+
<body class="gradient-bg" onload="if (isU2fSupported()) verifyU2f()">
6983
<div class="mdl-layout mdl-layout--fixed-header fill-viewport">
7084
<header class="mdl-layout__header">
7185
<div class="mdl-layout__header-row">
@@ -88,12 +102,18 @@ function createHiddenInput(name) {
88102
</h1>
89103
</div>
90104

91-
<div class="mdl-card__title center" >
92-
<p class="mdl-card__subtitle-text">
105+
<div class="mdl-card__title center hide" id="supported">
106+
<p class="mdl-card__subtitle-text center">
93107
<?= $this->t('{material:mfa:u2f_instructions}') ?>
94108
</p>
95109
</div>
96110

111+
<div class="mdl-card__title hide" id="unsupported">
112+
<p class="mdl-typography--text-center mdl-color-text--red">
113+
<?= $this->t('{material:mfa:u2f_unsupported}') ?>
114+
</p>
115+
</div>
116+
97117
<?php
98118
$message = $this->data['errorMessage'];
99119
if (! empty($message)) {
@@ -104,8 +124,7 @@ function createHiddenInput(name) {
104124
<?php
105125
}
106126
?>
107-
<div class="mdl-card__supporting-text"
108-
layout-children="column">
127+
<div class="mdl-card__supporting-text" layout-children="column">
109128
<p class="mdl-color-text--red error <?= ! empty($message) ? 'show' : 'hide' ?>">
110129
<i class="material-icons">error</i>
111130

www/bowser.1.8.0.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)