Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/webauthn.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

return [

/*
|--------------------------------------------------------------------------
| Enable passkey login
|--------------------------------------------------------------------------
|
| Whether or not the passkey feature should be enabled,
|
*/

'enable_login_with_passkey' => env('STATAMIC_PASSKEY_ENABLED', true),

/*
|--------------------------------------------------------------------------
| Allow password logins to be used when user has a passkey
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/users/PublishForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</template>
<DropdownMenu>
<DropdownItem :text="__('Edit Blueprint')" icon="blueprint-edit" v-if="canEditBlueprint" :href="actions.editBlueprint" />
<DropdownItem :text="__('Passkeys')" icon="key" :href="cp_url('passkeys')" />
<DropdownItem :text="__('Passkeys')" icon="key" :href="cp_url('passkeys')" v-if="passkeyEnabled" />
<DropdownSeparator v-if="canEditBlueprint && itemActions.length" />
<DropdownItem
v-for="action in itemActions"
Expand Down Expand Up @@ -122,6 +122,7 @@ export default {
canEditBlueprint: Boolean,
requiresCurrentPassword: Boolean,
twoFactor: Object,
passkeyEnabled: Boolean
},

data() {
Expand Down
7 changes: 4 additions & 3 deletions resources/js/pages/auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defineOptions({ layout: Outside });
const props = defineProps([
'errors',
'emailLoginEnabled',
'passkeyEnabled',
'passkeyOptionsUrl',
'passkeyVerifyUrl',
'oauthEnabled',
Expand Down Expand Up @@ -55,7 +56,7 @@ const submit = () => {
const passkey = usePasskey();

const showPasskeyLogin = computed(() => {
return props.emailLoginEnabled && passkey.supported;
return props.passkeyEnabled && props.emailLoginEnabled && passkey.supported;
})

const emailAutocomplete = computed(() => {
Expand Down Expand Up @@ -111,7 +112,7 @@ onMounted(() => {
<template #actions>
<Link
:href="forgotPasswordUrl"
class="text-ui-accent-text text-sm hover:text-ui-accent-text/80"
class="text-sm text-ui-accent-text hover:text-ui-accent-text/80"
tabindex="6"
v-text="__('Forgot password?')"
/>
Expand All @@ -137,7 +138,7 @@ onMounted(() => {
/>
<ErrorMessage v-if="passkey.error.value" :text="passkey.error.value" />
</template>
<div v-if="showOAuth" class="flex gap-4 justify-center items-center">
<div v-if="showOAuth" class="flex items-center justify-center gap-4">
<Button
v-for="provider in providers"
:key="provider.name"
Expand Down
4 changes: 3 additions & 1 deletion resources/js/pages/users/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ defineProps([
'itemActions',
'itemActionUrl',
'twoFactor',
'passkeyEnabled'
]);
</script>

<template>
<div class="max-w-5xl 3xl:max-w-6xl mx-auto" data-max-width-wrapper>
<div class="max-w-5xl mx-auto 3xl:max-w-6xl" data-max-width-wrapper>
<Head :title="__('Edit User')" />

<UserPublishForm
Expand All @@ -37,6 +38,7 @@ defineProps([
:initial-item-actions="itemActions"
:item-action-url="itemActionUrl"
:two-factor="twoFactor"
:passkey-enabled="passkeyEnabled"
/>
</div>
</template>
1 change: 1 addition & 0 deletions src/Http/Controllers/CP/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function showLoginForm(Request $request)
'referer' => $this->getReferrer($request),
'forgotPasswordUrl' => cp_route('password.request'),
'submitUrl' => cp_route('login'),
'passkeyEnabled' => config('statamic.webauthn.enable_login_with_passkey'),
'passkeyOptionsUrl' => cp_route('passkeys.auth.options'),
'passkeyVerifyUrl' => cp_route('passkeys.auth'),
]);
Expand Down
5 changes: 5 additions & 0 deletions src/Http/Controllers/CP/Auth/PasskeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class PasskeyController
{
public function index()
{
// redirect if passkeys are disabled
if (! config('statamic.webauthn.enable_login_with_passkey')) {
return redirect(cp_route('users.edit', User::current()->id()));
}

return Inertia::render('users/Passkeys', [
'passkeys' => User::current()->passkeys()->map(function (Passkey $passkey) {
return [
Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/CP/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public function edit(Request $request, $user)
],
],
] : null,
'passkeyEnabled' => config('statamic.webauthn.enable_login_with_passkey'),
];

if ($request->wantsJson()) {
Expand Down