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

Commit 4e94f89

Browse files
author
Billy Clark
committed
users with multiple MFA options configured needed an ability to use them.
1 parent f1356bc commit 4e94f89

File tree

7 files changed

+81
-19
lines changed

7 files changed

+81
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ If configured, an alert will be shown to the user filled with the content of tha
190190
5. Click **hub-discovery**
191191
6. Click **idp4**
192192
7. Login as a "multiple option" user: `username=`**has_all** `password=`**a**
193-
7. TODO: add remaining steps
193+
8. Click **MORE OPTIONS**
194194

195195
### Announcements functionality
196196
1. Goto [http://ssp-hub2.local:8081](http://ssp-hub2.local:8081)

dictionaries/mfa.definition.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@
108108
"fr": "TODO",
109109
"ko": "TODO"
110110
},
111+
"use_others": {
112+
"en": "More options",
113+
"es": "TODO",
114+
"fr": "TODO",
115+
"ko": "TODO"
116+
},
117+
"use_u2f": {
118+
"en": "Use my security key instead",
119+
"es": "TODO",
120+
"fr": "TODO",
121+
"ko": "TODO"
122+
},
123+
"use_totp": {
124+
"en": "Use my verification app instead",
125+
"es": "TODO",
126+
"fr": "TODO",
127+
"ko": "TODO"
128+
},
129+
"use_backupcode": {
130+
"en": "Use a backup code instead",
131+
"es": "TODO",
132+
"fr": "TODO",
133+
"ko": "TODO"
134+
},
111135
"button_verify": {
112136
"en": "Verify",
113137
"es": "TODO",

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
version: '2.0'
2-
#TODO: update README with local mfa testing steps
32

43
services:
54
hub:

themes/material/mfa/other_mfas.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!-- used type=button to avoid form submission on click -->
2+
<button id="others" type="button" class="mdl-button mdl-js-button">
3+
<span class="mdl-typography--caption">
4+
<?= $this->t('{material:mfa:use_others}') ?>
5+
</span>
6+
</button>
7+
<ul class="mdl-menu mdl-js-menu mdl-menu--top-left" data-mdl-for="others">
8+
<?php
9+
$mfaOptions = $this->data['mfaOptions'];
10+
$currentMfaId = $this->data['formData']['mfaId'];
11+
12+
function excludeSelf($others, $selfId) {
13+
return array_filter($others, function($option) use ($selfId) {
14+
return $option['id'] != $selfId;
15+
});
16+
}
17+
18+
foreach (excludeSelf($mfaOptions, $currentMfaId) as $otherOption) {
19+
?>
20+
<li class="mdl-menu__item"
21+
onclick="location.href += '&mfaId=<?= $otherOption['id'] ?>'">
22+
<span class="mdl-typography--caption">
23+
<?= $this->t('{material:mfa:use_'.$otherOption['type'].'}') ?>
24+
</span>
25+
</li>
26+
<?php
27+
}
28+
?>
29+
</ul>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</div>
6969

7070
<script>
71-
ga('send','event','error','backupcode', '<?= $message ?>');
71+
ga('send','event','error','backupcode','<?= $message ?>');
7272
</script>
7373
<?php
7474
}
@@ -81,15 +81,18 @@ class="mdl-button mdl-button--raised mdl-button--primary">
8181
<?= $this->t('{material:mfa:button_verify}') ?>
8282
</button>
8383
</div>
84+
85+
<div layout-children="column" child-spacing="center">
86+
<?php include __DIR__ . '/other_mfas.php' ?>
87+
</div>
8488
</div>
8589

8690
<div>
8791
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
8892
<span class="mdl-checkbox__label">
8993
<?= $this->t('{material:mfa:remember_this}') ?>
9094
</span>
91-
<input type="checkbox" name="rememberMe" value="true" checked
92-
class="mdl-checkbox__input"/>
95+
<input type="checkbox" name="rememberMe" checked class="mdl-checkbox__input"/>
9396
</label>
9497
</div>
9598
</form>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</div>
6969

7070
<script>
71-
ga('send','event','error','totp', '<?= $message ?>');
71+
ga('send','event','error','totp','<?= $message ?>');
7272
</script>
7373
<?php
7474
}
@@ -81,15 +81,18 @@ class="mdl-button mdl-button--raised mdl-button--primary">
8181
<?= $this->t('{material:mfa:button_verify}') ?>
8282
</button>
8383
</div>
84+
85+
<div layout-children="column" child-spacing="center">
86+
<?php include __DIR__ . '/other_mfas.php' ?>
87+
</div>
8488
</div>
8589

8690
<div>
8791
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
8892
<span class="mdl-checkbox__label">
8993
<?= $this->t('{material:mfa:remember_this}') ?>
9094
</span>
91-
<input type="checkbox" name="rememberMe" value="true" checked
92-
class="mdl-checkbox__input"/>
95+
<input type="checkbox" name="rememberMe" checked class="mdl-checkbox__input"/>
9396
</label>
9497
</div>
9598
</form>

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function handleError(u2fResponse) {
2929

3030
var errorNode = document.querySelector('p.error');
3131

32-
errorNode.classList.add('show');
32+
errorNode.classList.remove('hide');
3333
errorNode.querySelector('span').textContent = message;
3434

3535
offerRetry();
@@ -38,7 +38,7 @@ function handleError(u2fResponse) {
3838
function offerRetry() {
3939
var retryButton = document.querySelector('.mdl-button.mdl-color-text--red');
4040

41-
retryButton.classList.add('show');
41+
retryButton.classList.remove('hide');
4242
}
4343

4444
function submitForm(u2fResponse) {
@@ -73,6 +73,7 @@ function createHiddenInput(name) {
7373
</span>
7474
</div>
7575
</header>
76+
7677
<main class="mdl-layout__content" layout-children="column">
7778
<form layout-children="column" method="POST">
7879
<?php
@@ -103,18 +104,17 @@ function createHiddenInput(name) {
103104

104105
<?php
105106
$message = $this->data['errorMessage'];
106-
107107
if (! empty($message)) {
108108
?>
109109
<script>
110-
ga('send','event','error','u2f', '<?= $message ?>');
110+
ga('send','event','error','u2f','<?= $message ?>');
111111
</script>
112112
<?php
113113
}
114114
?>
115115
<div class="mdl-card__supporting-text"
116116
layout-children="column">
117-
<p class="mdl-color-text--red error <?= empty($message) ? 'hide' : 'show' ?>">
117+
<p class="mdl-color-text--red error <?= ! empty($message) ? 'show' : 'hide' ?>">
118118
<i class="material-icons">error</i>
119119

120120
<span class="mdl-typography--caption">
@@ -125,11 +125,16 @@ function createHiddenInput(name) {
125125

126126
<div class="mdl-card__actions" layout-children="row">
127127
<span flex></span>
128-
<!-- used input instead of button to avoid form submission on click -->
129-
<input type="button" onclick="verifyU2f()"
130-
class="mdl-button mdl-color-text--red hide"
131-
value="<?= $this->t('{material:mfa:button_try_again}') ?>">
128+
<!-- used type=button to avoid form submission on click -->
129+
<button type="button" onclick="verifyU2f()"
130+
class="mdl-button mdl-color-text--red <?= ! empty($message) ? 'show' : 'hide' ?>">
131+
<?= $this->t('{material:mfa:button_try_again}') ?>
132+
</button>
133+
134+
</div>
132135

136+
<div layout-children="column" child-spacing="center">
137+
<?php include __DIR__ . '/other_mfas.php' ?>
133138
</div>
134139
</div>
135140

@@ -138,8 +143,7 @@ class="mdl-button mdl-color-text--red hide"
138143
<span class="mdl-checkbox__label">
139144
<?= $this->t('{material:mfa:remember_this}') ?>
140145
</span>
141-
<input type="checkbox" name="rememberMe" value="true" checked
142-
class="mdl-checkbox__input"/>
146+
<input type="checkbox" name="rememberMe" checked class="mdl-checkbox__input"/>
143147
</label>
144148
</div>
145149
</form>

0 commit comments

Comments
 (0)