You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Section.vue 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!--
  2. - @copyright 2020, Roeland Jago Douma <roeland@famdouma.nl>
  3. -
  4. - @author Roeland Jago Douma <roeland@famdouma.nl>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -->
  21. <template>
  22. <div id="security-webauthn" class="section">
  23. <h2>{{ t('settings', 'Passwordless Authentication') }}</h2>
  24. <p class="settings-hint hidden-when-empty">
  25. {{ t('settings', 'Set up your account for passwordless authentication following the FIDO2 standard.') }}
  26. </p>
  27. <p v-if="devices.length === 0">
  28. {{ t('twofactor_u2f', 'No devices configured.') }}
  29. </p>
  30. <p v-else>
  31. {{ t('twofactor_u2f', 'The following devices are configured for your account:') }}
  32. </p>
  33. <Device v-for="device in sortedDevices"
  34. :key="device.id"
  35. :name="device.name"
  36. @delete="deleteDevice(device.id)" />
  37. <p v-if="!hasPublicKeyCredential" class="warning">
  38. {{ t('settings', 'Your browser does not support Webauthn.') }}
  39. </p>
  40. <AddDevice v-if="hasPublicKeyCredential" :isHttps="isHttps" @added="deviceAdded" />
  41. </div>
  42. </template>
  43. <script>
  44. import confirmPassword from '@nextcloud/password-confirmation'
  45. import sortBy from 'lodash/fp/sortBy'
  46. import AddDevice from './AddDevice'
  47. import Device from './Device'
  48. import logger from '../../logger'
  49. import { removeRegistration } from '../../service/WebAuthnRegistrationSerice'
  50. const sortByName = sortBy('name')
  51. export default {
  52. components: {
  53. AddDevice,
  54. Device,
  55. },
  56. props: {
  57. initialDevices: {
  58. type: Array,
  59. required: true,
  60. },
  61. isHttps: {
  62. type: Boolean,
  63. default: false,
  64. },
  65. hasPublicKeyCredential: {
  66. type: Boolean,
  67. default: false,
  68. },
  69. },
  70. data() {
  71. return {
  72. devices: this.initialDevices,
  73. }
  74. },
  75. computed: {
  76. sortedDevices() {
  77. return sortByName(this.devices)
  78. },
  79. },
  80. methods: {
  81. deviceAdded(device) {
  82. logger.debug(`adding new device to the list ${device.id}`)
  83. this.devices.push(device)
  84. },
  85. async deleteDevice(id) {
  86. logger.info(`deleting webauthn device ${id}`)
  87. await confirmPassword()
  88. await removeRegistration(id)
  89. this.devices = this.devices.filter(d => d.id !== id)
  90. logger.info(`webauthn device ${id} removed successfully`)
  91. },
  92. },
  93. }
  94. </script>
  95. <style scoped>
  96. </style>