fix(core): adjust fronend code for changes in webauthn library

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/51521/head
Ferdinand Thiessen 7 months ago
parent 823551d5c3
commit 60dd89e04c
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
  1. 6
      apps/settings/src/service/WebAuthnRegistrationSerice.ts
  2. 14
      core/src/components/login/PasswordLessLoginForm.vue
  3. 2
      core/src/services/WebAuthnAuthenticationService.ts

@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later * SPDX-License-Identifier: AGPL-3.0-or-later
*/ */
import type { RegistrationResponseJSON } from '@simplewebauthn/types' import type { PublicKeyCredentialCreationOptionsJSON, RegistrationResponseJSON } from '@simplewebauthn/types'
import { translate as t } from '@nextcloud/l10n' import { translate as t } from '@nextcloud/l10n'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
@ -21,9 +21,9 @@ export async function startRegistration() {
try { try {
logger.debug('Fetching webauthn registration data') logger.debug('Fetching webauthn registration data')
const { data } = await axios.get(url) const { data } = await axios.get<PublicKeyCredentialCreationOptionsJSON>(url)
logger.debug('Start webauthn registration') logger.debug('Start webauthn registration')
const attrs = await registerWebAuthn(data) const attrs = await registerWebAuthn({ optionsJSON: data })
return attrs return attrs
} catch (e) { } catch (e) {
logger.error(e as Error) logger.error(e as Error)

@ -5,11 +5,15 @@
<template> <template>
<form v-if="(isHttps || isLocalhost) && supportsWebauthn" <form v-if="(isHttps || isLocalhost) && supportsWebauthn"
ref="loginForm" ref="loginForm"
aria-labelledby="password-less-login-form-title"
class="password-less-login-form" class="password-less-login-form"
method="post" method="post"
name="login" name="login"
@submit.prevent="submit"> @submit.prevent="submit">
<h2>{{ t('core', 'Log in with a device') }}</h2> <h2 id="password-less-login-form-title">
{{ t('core', 'Log in with a device') }}
</h2>
<NcTextField required <NcTextField required
:value="user" :value="user"
:autocomplete="autoCompleteAllowed ? 'on' : 'off'" :autocomplete="autoCompleteAllowed ? 'on' : 'off'"
@ -41,9 +45,11 @@
</NcEmptyContent> </NcEmptyContent>
</template> </template>
<script> <script type="ts">
import { browserSupportsWebAuthn } from '@simplewebauthn/browser' import { browserSupportsWebAuthn } from '@simplewebauthn/browser'
import { defineComponent } from 'vue'
import { import {
NoValidCredentials,
startAuthentication, startAuthentication,
finishAuthentication, finishAuthentication,
} from '../../services/WebAuthnAuthenticationService.ts' } from '../../services/WebAuthnAuthenticationService.ts'
@ -56,7 +62,7 @@ import LoginButton from './LoginButton.vue'
import LockOpenIcon from 'vue-material-design-icons/LockOpen.vue' import LockOpenIcon from 'vue-material-design-icons/LockOpen.vue'
import logger from '../../logger' import logger from '../../logger'
export default { export default defineComponent({
name: 'PasswordLessLoginForm', name: 'PasswordLessLoginForm',
components: { components: {
LoginButton, LoginButton,
@ -143,7 +149,7 @@ export default {
// noop // noop
}, },
}, },
} })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

@ -27,7 +27,7 @@ export async function startAuthentication(loginName: string) {
logger.error('No valid credentials returned for webauthn') logger.error('No valid credentials returned for webauthn')
throw new NoValidCredentials() throw new NoValidCredentials()
} }
return await startWebauthnAuthentication(data) return await startWebauthnAuthentication({ optionsJSON: data })
} }
/** /**

Loading…
Cancel
Save