PHPackages                             scriptoshi/livewire-webauthn - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. scriptoshi/livewire-webauthn

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

scriptoshi/livewire-webauthn
============================

WebAuthn authentication package for Laravel 12 using Livewire

1.0.2(5mo ago)120MITPHPPHP ^8.2

Since Mar 18Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/scriptoshi/livewire-webauthn)[ Packagist](https://packagist.org/packages/scriptoshi/livewire-webauthn)[ RSS](/packages/scriptoshi-livewire-webauthn/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (10)Versions (4)Used By (0)

Laravel Livewire WebAuthn
=========================

[](#laravel-livewire-webauthn)

A modern WebAuthn (FIDO2) authentication package for Laravel 12 using Livewire and Flux components. Enables passwordless and two-factor authentication using security keys, biometrics, and mobile devices.

Overview
--------

[](#overview)

Laravel Livewire WebAuthn provides an easy way to integrate WebAuthn (Web Authentication) capabilities into your Laravel 12 application. Built with Livewire and Flux components, it offers a modern, interactive user experience with minimal configuration.

### Features

[](#features)

- 🔐 FIDO2 WebAuthn standard compliant
- 🔑 Support for security keys (YubiKey, Titan, etc.)
- 👆 Support for biometrics (TouchID, FaceID, Windows Hello)
- 📱 Support for mobile devices as authenticators
- ⚡ Livewire-powered interactive components
- 🎨 Beautiful UI with Flux components
- 🌓 Full dark mode support
- 🛠️ Simple integration with existing authentication systems
- 🛡️ On-demand WebAuthn confirmation modals
- 🔄 Compatible with Laravel 12 and Livewire 3

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12.x
- Livewire 3.x
- Flux components
- A browser that supports WebAuthn (most modern browsers)

Installation
------------

[](#installation)

### 1. Install the package via Composer

[](#1-install-the-package-via-composer)

```
composer require scriptoshi/livewire-webauthn
```

### 2. (Optional) Publish the assets if you need to customize them

[](#2-optional-publish-the-assets-if-you-need-to-customize-them)

```
php artisan vendor:publish --provider="Scriptoshi\LivewireWebauthn\WebAuthnServiceProvider" --tag="config"
php artisan vendor:publish --provider="Scriptoshi\LivewireWebauthn\WebAuthnServiceProvider" --tag="views"
php artisan vendor:publish --provider="Scriptoshi\LivewireWebauthn\WebAuthnServiceProvider" --tag="migrations"
```

### 3. Run the migrations

[](#3-run-the-migrations)

This will add the required columns to your users table and create the credentials table.

```
php artisan migrate
```

### 4. Include the WebAuthnAuthenticatable trait in your User model

[](#4-include-the-webauthnauthenticatable-trait-in-your-user-model)

```
use Scriptoshi\LivewireWebauthn\Traits\WebAuthnAuthenticatable;

class User extends Authenticatable
{
    use WebAuthnAuthenticatable;

    // ...
}
```

Configuration
-------------

[](#configuration)

The package comes with sensible defaults, but you can customize it using the corresponding `.env` variables. Add the following lines to your .env to customize the configuration:

```
# Enable or disable WebAuthn functionality entirely
WEBAUTHN_ENABLED=true

# Relying party name (shown to users during authentication)
WEBAUTHN_RP_NAME="${APP_NAME}"

# Relying party ID (usually your domain name)
WEBAUTHN_RP_ID="${APP_URL}"

# Table name for WebAuthn credentials
WEBAUTHN_CREDENTIALS_TABLE=webauthn_credentials

# Timeout for WebAuthn verification (in seconds, default 15 minutes)
WEBAUTHN_TIMEOUT=900

# Attestation conveyance preference (none, indirect, direct, enterprise)
WEBAUTHN_ATTESTATION_CONVEYANCE=none

# User verification requirement (required, preferred, discouraged)
WEBAUTHN_USER_VERIFICATION=preferred
```

Basic Usage
-----------

[](#basic-usage)

### Integrating with Login as Second factor Auth.

[](#integrating-with-login-as-second-factor-auth)

Add the middleware to intercept your login logic. Note: this is the route for `POST` when users submit the login form. In volt components this route is missing !.

1. Add this to your `routes/web.php`:

```
use Scriptoshi\LivewireWebauthn\Http\Middleware\WebAuthn;

// Intercept login attempts and handle WebAuthn if needed
Route::post('/login', [AuthenticatedSessionController::class, 'store'])
    ->middleware(['guest', WebAuthn::class])
    ->name('login');
```

### Adding WebAuthn Management to User Profile

[](#adding-webauthn-management-to-user-profile)

Add the Livewire component to your user profile or settings page:

```

```

With Laravel 12 Starter Kit, you can add a new section for WebAuthn management:

1. Edit `resources/views/components/settings/layout.blade.php` to add the menu item:

```

    {{ __('Profile') }}
    {{ __('Password') }}
    {{ __('Appearance') }}

    {{ __('Security Keys') }}

```

2. Then Create a WebAuthn view: `resources/views/livewire/settings/webauthn.blade.php`

```
