From 53db05a1f67fc974dba904ec158b2d67fa72df95 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma
Date: Sun, 9 Feb 2020 20:06:08 +0100
Subject: Start with webauthn
Signed-off-by: Roeland Jago Douma
Signed-off-by: npmbuildbot[bot]
---
core/src/components/login/LoginButton.vue | 56 ++++++
core/src/components/login/LoginForm.vue | 19 +-
.../src/components/login/PasswordLessLoginForm.vue | 208 +++++++++++++++++++++
core/src/login.js | 3 +
core/src/service/WebAuthnAuthenticationService.js | 37 ++++
core/src/views/Login.vue | 36 +++-
6 files changed, 344 insertions(+), 15 deletions(-)
create mode 100644 core/src/components/login/LoginButton.vue
create mode 100644 core/src/components/login/PasswordLessLoginForm.vue
create mode 100644 core/src/service/WebAuthnAuthenticationService.js
(limited to 'core/src')
diff --git a/core/src/components/login/LoginButton.vue b/core/src/components/login/LoginButton.vue
new file mode 100644
index 00000000000..f7d426e6c63
--- /dev/null
+++ b/core/src/components/login/LoginButton.vue
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
diff --git a/core/src/components/login/LoginForm.vue b/core/src/components/login/LoginForm.vue
index 687896ceb54..a20ce6dc4c2 100644
--- a/core/src/components/login/LoginForm.vue
+++ b/core/src/components/login/LoginForm.vue
@@ -20,7 +20,8 @@
-->
-
-
+
@@ -135,9 +124,11 @@
+
+
diff --git a/core/src/login.js b/core/src/login.js
index 7270442c83e..bfcfabf169f 100644
--- a/core/src/login.js
+++ b/core/src/login.js
@@ -64,5 +64,8 @@ new View({
resetPasswordTarget: fromStateOr('resetPasswordTarget', ''),
resetPasswordUser: fromStateOr('resetPasswordUser', ''),
directLogin: query.direct === '1',
+ hasPasswordless: fromStateOr('webauthn-available', false),
+ isHttps: window.location.protocol === 'https:',
+ hasPublicKeyCredential: typeof (window.PublicKeyCredential) !== 'undefined',
},
}).$mount('#login')
diff --git a/core/src/service/WebAuthnAuthenticationService.js b/core/src/service/WebAuthnAuthenticationService.js
new file mode 100644
index 00000000000..91f19177066
--- /dev/null
+++ b/core/src/service/WebAuthnAuthenticationService.js
@@ -0,0 +1,37 @@
+/**
+ * @copyright 2020, Roeland Jago Douma
+ *
+ * @author Roeland Jago Douma
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+import Axios from '@nextcloud/axios'
+import { generateUrl } from '@nextcloud/router'
+
+export function startAuthentication(loginName) {
+ const url = generateUrl('/login/webauthn/start')
+
+ return Axios.post(url, { loginName })
+ .then(resp => resp.data)
+}
+
+export function finishAuthentication(data) {
+ const url = generateUrl('/login/webauthn/finish')
+
+ return Axios.post(url, { data })
+ .then(resp => resp.data)
+}
diff --git a/core/src/views/Login.vue b/core/src/views/Login.vue
index baea18cbe3c..a50e6c5c72c 100644
--- a/core/src/views/Login.vue
+++ b/core/src/views/Login.vue
@@ -22,7 +22,7 @@
-
+
import LoginForm from '../components/login/LoginForm.vue'
+import PasswordLessLoginForm from '../components/login/PasswordLessLoginForm.vue'
import ResetPassword from '../components/login/ResetPassword.vue'
import UpdatePassword from '../components/login/UpdatePassword.vue'
@@ -76,6 +96,7 @@ export default {
name: 'Login',
components: {
LoginForm,
+ PasswordLessLoginForm,
ResetPassword,
UpdatePassword,
},
@@ -120,11 +141,24 @@ export default {
type: Boolean,
default: false,
},
+ hasPasswordless: {
+ type: Boolean,
+ default: false,
+ },
+ isHttps: {
+ type: Boolean,
+ default: false,
+ },
+ hasPublicKeyCredential: {
+ type: Boolean,
+ default: false,
+ },
},
data() {
return {
loading: false,
user: this.username,
+ passwordlessLogin: false,
resetPassword: false,
}
},
--
cgit v1.2.3