spatie/laravel-passkeys
Add passkey (WebAuthn) login to Laravel without passwords. Includes Livewire components to register/generate passkeys and a Blade component to authenticate users using device-stored credentials (1Password, macOS Keychain, etc.).
Authenticatable, HasApiTokens) and integrates seamlessly with Livewire/Blade, reducing architectural friction.PasskeyRegisteredEvent) for workflows like audit logging, analytics, or multi-factor enforcement.Passkey model, middleware). Existing auth flows (e.g., email/password) remain untouched.passkeys table with user_id, credential_id, and metadata—compatible with Laravel’s migrations and Eloquent.web-auth/webauthn-lib (v5.3+), which may introduce breaking changes (e.g., CredentialRecord type shifts). Mitigate via:
^5.3) in composer.json.webauthn-lib’s test vectors.relyingParty.name or id can break authentication. Use Laravel’s config('passkeys.relying_party').Passkey model’s data field is encrypted if storing sensitive metadata (e.g., publicKeyCredential).attestation: "none" vs. "direct").GeneratePasskey component).Passkey model handles credential storage/retrieval.EnsurePasskeyIsVerified for protected routes.navigator.credentials.create()/get().passkeys table with user_id, credential_id (base64), and transports (e.g., ["internal", "usb"]).Phase 1: Pilot (Low Risk)
composer require spatie/laravel-passkeys.php artisan vendor:publish --tag="passkeys-config".Passkey model to User model (hasMany relationship).@livewire('generate-passkey').Phase 2: Core Integration
@livewire('authenticate-with-passkey')).LoginController to handle passkey auth alongside passwords:
use Spatie\Passkeys\AuthenticatesWithPasskeys;
class LoginController extends Controller {
use AuthenticatesWithPasskeys;
}
Route::middleware(['auth', 'passkey.verified'])->group(function () {
// Admin routes
});
config/passkeys.php:
'relying_party' => [
'name' => 'Your App Name',
'id' => 'yourdomain.com',
],
'allowed_origins' => ['https://yourdomain.com', 'https://app.yourdomain.com'],
Phase 3: Optimization
authenticateWithPasskey($remember = true).user->passkeys()->delete($credentialId).PasskeyRegisteredEvent for custom logic (e.g., send welcome email with passkey tips).passkeys::messages.authenticate).webauthn-lib dependencies).webauthn-lib installations (use composer why-not spatie/laravel-passkeys).composer require livewire/livewire.webauthn-lib is compatible with your PHP version.config/passkeys.php before running migrations.Passkey model to User before using auth methods.webauthn-lib for breaking changes (e.g., #120).spatie/laravel-passkeys regularly (MIT license allows forks if needed).passkeys.user_id and credential_id for performance.PasskeyRegisteredEvent::listen(function ($event) {
Log::info('Passkey registered', ['user_id' => $event->user->id]);
});
How can I help you explore Laravel packages today?