Skip to content

Commit 86080e6

Browse files
MorrisJobkeartonge
authored andcommitted
Allow WebAuthn on localhost as well
* browsers typically whiteliste this as well - https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API * for developing purposes see https://developer.chrome.com/docs/devtools/webauthn/ Signed-off-by: Morris Jobke <hey@morrisjobke.de> Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent ff8cfbb commit 86080e6

10 files changed

Lines changed: 37 additions & 15 deletions

File tree

apps/settings/js/vue-settings-personal-webauthn.js

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

apps/settings/js/vue-settings-personal-webauthn.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/settings/src/components/WebAuthn/AddDevice.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
-->
2121

2222
<template>
23-
<div v-if="!isHttps">
23+
<div v-if="!isHttps && !isLocalhost">
2424
{{ t('settings', 'Passwordless authentication requires a secure connection.') }}
2525
</div>
2626
<div v-else>
@@ -89,6 +89,10 @@ export default {
8989
type: Boolean,
9090
default: false,
9191
},
92+
isLocalhost: {
93+
type: Boolean,
94+
default: false,
95+
},
9296
},
9397
data() {
9498
return {

apps/settings/src/components/WebAuthn/Section.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
{{ t('settings', 'Your browser does not support WebAuthn.') }}
4141
</p>
4242

43-
<AddDevice v-if="hasPublicKeyCredential" :is-https="isHttps" @added="deviceAdded" />
43+
<AddDevice v-if="hasPublicKeyCredential"
44+
:is-https="isHttps"
45+
:is-localhost="isLocalhost"
46+
@added="deviceAdded" />
4447
</div>
4548
</template>
4649

@@ -69,6 +72,10 @@ export default {
6972
type: Boolean,
7073
default: false,
7174
},
75+
isLocalhost: {
76+
type: Boolean,
77+
default: false,
78+
},
7279
hasPublicKeyCredential: {
7380
type: Boolean,
7481
default: false,

apps/settings/src/main-personal-webauth.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ new View({
3636
propsData: {
3737
initialDevices: devices,
3838
isHttps: window.location.protocol === 'https:',
39+
isLocalhost: window.location.hostname === 'localhost',
3940
hasPublicKeyCredential: typeof (window.PublicKeyCredential) !== 'undefined',
4041
},
4142
}).$mount('#security-webauthn')

core/js/dist/login.js

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

core/js/dist/login.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/components/login/PasswordLessLoginForm.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<form v-if="isHttps && hasPublicKeyCredential"
2+
<form v-if="(isHttps || isLocalhost) && hasPublicKeyCredential"
33
ref="loginForm"
44
method="post"
55
name="login"
@@ -32,7 +32,7 @@
3232
<div v-else-if="!hasPublicKeyCredential">
3333
{{ t('core', 'Passwordless authentication is not supported in your browser.') }}
3434
</div>
35-
<div v-else-if="!isHttps">
35+
<div v-else-if="!isHttps && !isLocalhost">
3636
{{ t('core', 'Passwordless authentication is only available over a secure connection.') }}
3737
</div>
3838
</template>
@@ -73,6 +73,10 @@ export default {
7373
type: Boolean,
7474
default: false,
7575
},
76+
isLocalhost: {
77+
type: Boolean,
78+
default: false,
79+
},
7680
hasPublicKeyCredential: {
7781
type: Boolean,
7882
default: false,

core/src/login.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ new View({
7171
hasPasswordless: fromStateOr('webauthn-available', false),
7272
countAlternativeLogins: fromStateOr('countAlternativeLogins', false),
7373
isHttps: window.location.protocol === 'https:',
74+
isLocalhost: window.location.hostname === 'localhost',
7475
hasPublicKeyCredential: typeof (window.PublicKeyCredential) !== 'undefined',
7576
hideLoginForm: fromStateOr('hideLoginForm', false),
7677
},

core/src/views/Login.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
:inverted-colors="invertedColors"
7474
:auto-complete-allowed="autoCompleteAllowed"
7575
:is-https="isHttps"
76+
:is-localhost="isLocalhost"
7677
:has-public-key-credential="hasPublicKeyCredential"
7778
@submit="loading = true" />
7879
<a href="#" @click.prevent="passwordlessLogin = false">
@@ -176,6 +177,10 @@ export default {
176177
type: Boolean,
177178
default: false,
178179
},
180+
isLocalhost: {
181+
type: Boolean,
182+
default: false,
183+
},
179184
hasPublicKeyCredential: {
180185
type: Boolean,
181186
default: false,

0 commit comments

Comments
 (0)