mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-16 09:42:29 -04:00
Enable Fortify passkeys (laravel/passkeys) with the @laravel/passkeys client. Users can sign in with a passkey, confirm sensitive actions with one, and add, rename, and delete passkeys on the Profile page. - Resolve the relying party for each request from the instance URL, then APP_URL, then localhost. Passkey routes return 404 on other hosts. - Add the is_passkey_enabled instance setting (Settings > Advanced). - Use a hex user handle (laravel/passkeys-server#41). - Rate limit the passkey routes by client IP. - Record audit events for registered, verified, and deleted passkeys.
56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
@props([
|
|
'optionsRoute' => 'passkey.login-options',
|
|
'submitRoute' => 'passkey.login',
|
|
'label' => 'Sign in with a passkey',
|
|
'autofill' => false,
|
|
])
|
|
|
|
@vite('resources/js/passkeys.js')
|
|
<div x-cloak x-show="supported" class="flex flex-col gap-2" x-data="{
|
|
supported: false,
|
|
loading: false,
|
|
error: null,
|
|
routes: { options: @js(route($optionsRoute)), submit: @js(route($submitRoute)) },
|
|
init() {
|
|
const ready = () => {
|
|
this.supported = Boolean(window.Passkeys?.isSupported());
|
|
if (this.supported && @js($autofill)) {
|
|
this.autofill();
|
|
}
|
|
};
|
|
window.Passkeys ? ready() : window.addEventListener('passkeys:ready', ready, { once: true });
|
|
},
|
|
done(response) {
|
|
if (response) {
|
|
window.location.href = response.redirect || '/';
|
|
}
|
|
},
|
|
async autofill() {
|
|
try {
|
|
this.done(await window.Passkeys.autofill({ routes: this.routes }));
|
|
} catch (e) {
|
|
this.error = e.message;
|
|
}
|
|
},
|
|
async verify() {
|
|
this.loading = true;
|
|
this.error = null;
|
|
try {
|
|
this.done(await window.Passkeys.verify({ routes: this.routes }));
|
|
} catch (e) {
|
|
if (e.name !== 'UserCancelledError') {
|
|
this.error = e.message;
|
|
}
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
}">
|
|
<x-forms.button class="w-full justify-center" type="button" x-on:click="verify()" x-bind:disabled="loading">
|
|
{{ $label }}
|
|
</x-forms.button>
|
|
<template x-if="error">
|
|
<x-auth.alert type="error"><span x-text="error"></span></x-auth.alert>
|
|
</template>
|
|
</div>
|