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] --- .../settings/src/components/WebAuthn/AddDevice.vue | 215 +++++++++++++++++++++ apps/settings/src/components/WebAuthn/Device.vue | 65 +++++++ apps/settings/src/components/WebAuthn/Section.vue | 109 +++++++++++ apps/settings/src/logger.js | 27 +++ apps/settings/src/main-personal-webauth.js | 40 ++++ .../src/service/WebAuthnRegistrationSerice.js | 43 +++++ 6 files changed, 499 insertions(+) create mode 100644 apps/settings/src/components/WebAuthn/AddDevice.vue create mode 100644 apps/settings/src/components/WebAuthn/Device.vue create mode 100644 apps/settings/src/components/WebAuthn/Section.vue create mode 100644 apps/settings/src/logger.js create mode 100644 apps/settings/src/main-personal-webauth.js create mode 100644 apps/settings/src/service/WebAuthnRegistrationSerice.js (limited to 'apps/settings/src') diff --git a/apps/settings/src/components/WebAuthn/AddDevice.vue b/apps/settings/src/components/WebAuthn/AddDevice.vue new file mode 100644 index 00000000000..05b649ec313 --- /dev/null +++ b/apps/settings/src/components/WebAuthn/AddDevice.vue @@ -0,0 +1,215 @@ + + + + + + + diff --git a/apps/settings/src/components/WebAuthn/Device.vue b/apps/settings/src/components/WebAuthn/Device.vue new file mode 100644 index 00000000000..fc1bab3c8b0 --- /dev/null +++ b/apps/settings/src/components/WebAuthn/Device.vue @@ -0,0 +1,65 @@ + + + + + + + diff --git a/apps/settings/src/components/WebAuthn/Section.vue b/apps/settings/src/components/WebAuthn/Section.vue new file mode 100644 index 00000000000..cd09ec43c1a --- /dev/null +++ b/apps/settings/src/components/WebAuthn/Section.vue @@ -0,0 +1,109 @@ + + + + + + + diff --git a/apps/settings/src/logger.js b/apps/settings/src/logger.js new file mode 100644 index 00000000000..275771ce4c5 --- /dev/null +++ b/apps/settings/src/logger.js @@ -0,0 +1,27 @@ +/* + * @copyright 2020 Christoph Wurst + * + * @author 2020 Christoph Wurst + * + * @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 { getLoggerBuilder } from '@nextcloud/logger' + +export default getLoggerBuilder() + .setApp('settings') + .detectUser() + .build() diff --git a/apps/settings/src/main-personal-webauth.js b/apps/settings/src/main-personal-webauth.js new file mode 100644 index 00000000000..e6e302df5f8 --- /dev/null +++ b/apps/settings/src/main-personal-webauth.js @@ -0,0 +1,40 @@ +/** + * @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 Vue from 'vue' +import { loadState } from '@nextcloud/initial-state' + +import WebAuthnSection from './components/WebAuthn/Section' + +// eslint-disable-next-line camelcase +__webpack_nonce__ = btoa(OC.requestToken) + +Vue.prototype.t = t + +const View = Vue.extend(WebAuthnSection) +const devices = loadState('settings', 'webauthn-devices') +new View({ + propsData: { + initialDevices: devices, + isHttps: window.location.protocol === 'https:', + hasPublicKeyCredential: typeof (window.PublicKeyCredential) !== 'undefined', + }, +}).$mount('#security-webauthn') diff --git a/apps/settings/src/service/WebAuthnRegistrationSerice.js b/apps/settings/src/service/WebAuthnRegistrationSerice.js new file mode 100644 index 00000000000..4c82c5b9fa7 --- /dev/null +++ b/apps/settings/src/service/WebAuthnRegistrationSerice.js @@ -0,0 +1,43 @@ +/** + * @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 async function startRegistration() { + const url = generateUrl('/settings/api/personal/webauthn/registration') + + const resp = await axios.get(url) + return resp.data +} + +export async function finishRegistration(name, data) { + const url = generateUrl('/settings/api/personal/webauthn/registration') + + const resp = await axios.post(url, { name, data }) + return resp.data +} + +export async function removeRegistration(id) { + const url = generateUrl(`/settings/api/personal/webauthn/registration/${id}`) + + await axios.delete(url) +} -- cgit v1.2.3