Skip to content

Commit

Permalink
Merge pull request #27537 from nextcloud/fix/noid/webauthn-localhost
Browse files Browse the repository at this point in the history
Allow WebAuthn on localhost as well
  • Loading branch information
Pytal authored Jun 17, 2021
2 parents ae331de + 86080e6 commit 18ff261
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 15 deletions.
10 changes: 5 additions & 5 deletions apps/settings/js/vue-settings-personal-webauthn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-webauthn.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion apps/settings/src/components/WebAuthn/AddDevice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-->

<template>
<div v-if="!isHttps">
<div v-if="!isHttps && !isLocalhost">
{{ t('settings', 'Passwordless authentication requires a secure connection.') }}
</div>
<div v-else>
Expand Down Expand Up @@ -89,6 +89,10 @@ export default {
type: Boolean,
default: false,
},
isLocalhost: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand Down
9 changes: 8 additions & 1 deletion apps/settings/src/components/WebAuthn/Section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
{{ t('settings', 'Your browser does not support WebAuthn.') }}
</p>

<AddDevice v-if="hasPublicKeyCredential" :is-https="isHttps" @added="deviceAdded" />
<AddDevice v-if="hasPublicKeyCredential"
:is-https="isHttps"
:is-localhost="isLocalhost"
@added="deviceAdded" />
</div>
</template>

Expand Down Expand Up @@ -69,6 +72,10 @@ export default {
type: Boolean,
default: false,
},
isLocalhost: {
type: Boolean,
default: false,
},
hasPublicKeyCredential: {
type: Boolean,
default: false,
Expand Down
1 change: 1 addition & 0 deletions apps/settings/src/main-personal-webauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ new View({
propsData: {
initialDevices: devices,
isHttps: window.location.protocol === 'https:',
isLocalhost: window.location.hostname === 'localhost',
hasPublicKeyCredential: typeof (window.PublicKeyCredential) !== 'undefined',
},
}).$mount('#security-webauthn')
8 changes: 4 additions & 4 deletions core/js/dist/login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/login.js.map

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions core/src/components/login/PasswordLessLoginForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<form v-if="isHttps && hasPublicKeyCredential"
<form v-if="(isHttps || isLocalhost) && hasPublicKeyCredential"
ref="loginForm"
method="post"
name="login"
Expand Down Expand Up @@ -32,7 +32,7 @@
<div v-else-if="!hasPublicKeyCredential">
{{ t('core', 'Passwordless authentication is not supported in your browser.') }}
</div>
<div v-else-if="!isHttps">
<div v-else-if="!isHttps && !isLocalhost">
{{ t('core', 'Passwordless authentication is only available over a secure connection.') }}
</div>
</template>
Expand Down Expand Up @@ -73,6 +73,10 @@ export default {
type: Boolean,
default: false,
},
isLocalhost: {
type: Boolean,
default: false,
},
hasPublicKeyCredential: {
type: Boolean,
default: false,
Expand Down
1 change: 1 addition & 0 deletions core/src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ new View({
hasPasswordless: fromStateOr('webauthn-available', false),
countAlternativeLogins: fromStateOr('countAlternativeLogins', false),
isHttps: window.location.protocol === 'https:',
isLocalhost: window.location.hostname === 'localhost',
hasPublicKeyCredential: typeof (window.PublicKeyCredential) !== 'undefined',
hideLoginForm: fromStateOr('hideLoginForm', false),
},
Expand Down
5 changes: 5 additions & 0 deletions core/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
:inverted-colors="invertedColors"
:auto-complete-allowed="autoCompleteAllowed"
:is-https="isHttps"
:is-localhost="isLocalhost"
:has-public-key-credential="hasPublicKeyCredential"
@submit="loading = true" />
<a href="#" @click.prevent="passwordlessLogin = false">
Expand Down Expand Up @@ -176,6 +177,10 @@ export default {
type: Boolean,
default: false,
},
isLocalhost: {
type: Boolean,
default: false,
},
hasPublicKeyCredential: {
type: Boolean,
default: false,
Expand Down

0 comments on commit 18ff261

Please sign in to comment.