pioneer-dynamics / laravel-passkey
Easy Passkey integration for Laravel
Installs: 557
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/pioneer-dynamics/laravel-passkey
Requires
- laravel/framework: ^10.10 || ^11.0 || ^12.0
- svgta/webauthn: ^1.0
- symfony/clock: ^6.3 || ^7.0
- dev-master
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- dev-develop
- dev-mathewparet-patch-1
- dev-mathewparet-patch-security
This package is auto-updated.
Last update: 2025-10-12 13:13:16 UTC
README
Easy Passkey integration for Laravel
Click the thumbnail below to see a video of the package in action.:
Thank You
The core of the project uses svgta/webauthn library.
We are looking for contributors
We are looking for contributors to help improve the library and add compatibility for Livewire.
ALERT
!!!WARNING!!! The command
passkey:installcommand must be run ONLY on development and ONLY ONCE. Depending on the options provided, this command will publish the below files and modify them to suit your needs. Please find the details below.
- Config file, if
--configparameter is provided - Migration file
- Jetstream flavoured Inertia JS component files, if
--jetstream-inertiais provided.
!!WARNING!! Any existing files will be replaced.
Installation
You have two ways to run setup - 1, the Setup command in step #2 (below) or 2, the
vendor:publishcommand. I recommend thepasskey:installcommand since it takes care of replacing some placeholders in the published files apart from publishing them. Use the--tableand--usernameflags to change the defaults. These values default tousersandvendor:publishcommand you'll need to replace__USERNAME__,__TABLE__,__USERNAME_LABEL__and the__USERNAME_TYPE__placeholders manually. These placeholders can be found in thejs/Components/ConfirmsPasswordOrPasskey.vue,js/Components/ConfirmsPasskey.vue,js/Pages/Auth/LoginWithPasskey.vueand theconfig/passkey.phpfiles.
-
Require the library
composer install pioneer-dynamics/laravel-passkey -
Run the setup
Before running this command, run
php artisan passkey:install --helpto see understand all options.php artisan passkey:installThis will publish the config files, migrations and some Jetstream-Inertia flavoured vue files. It will also replace some contents of these published files.
-
Run the migrations
php artisan migrate -
Implement the
PasskeyUserinterface to you user model and add theHasPasskeystrait<?php namespace App\Models; use PioneerDynamics\LaravelPasskey\Traits\HassPasskeys; use PioneerDynamics\LaravelPasskey\Contracts\PasskeyUser; // ... use Illuminate\Foundation\Auth\User as Authenticatable; // ... class User extends Authenticatable implements PasskeyUser { // ... use HasPasskeys; // ... /** * If you wish to not use `HasPassKeys` trait, you must eager load `passkeys` * attribute like this: * */ // protected $with = ['passkeys']; /** * In addition to some helper methods, the below methods are defined * in the `HasPasskeys` trait. Override them here if needed. * * Below are the default definitions in `HasPasskeys` */ // public function getUsername() // { // // The username of the user (Shown by the browser passkey interface) // return $this->email; // } // // public function getUserId() // { // // The ID of the user // return $this->id; // } // // public function getDisplayName() // { // // The display name of the user // return $this->name; // } // // protected function generateUserImageFrom() // { // // return the attribute that holds the path to the user image (preferably public url) // return 'profile_photo_url'; // } // ... }
-
If you are using Laravel Jetstream with InertiaJS, you can can add the below to the
FortifyServiceProvider'sboot()command in order to override the default Login Vue and use the one provided by this package.<?php namespace App\Providers; // ... use Inertia\Inertia; use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Laravel\Fortify\Fortify; // ... class FortifyServiceProvider extends ServiceProvider { // ... /** * Bootstrap any application services. */ public function boot(): void { // ... Fortify::loginView(function () { return Inertia::render('Auth/LoginWithPasskey', [ 'canResetPassword' => Route::has('password.request'), 'status' => session('status'), ]); }); // ... } }
-
Replace the
<ConfirmsPassword/>component with<ConfirmsPasswordOrPasskey/>component whereever<ConfirmsPassword/>is used. The ``optionally accepts a:seconds` property which defines how long a validation should be valid for. Should you chose to use it, there should also be a corresponding `password.confirm` middleware for the route. -
Add
<PasskeyForm/>fromresources/js/Pages/Profile/Partials/PassKeyForm.vuetoresources/js/Pages/Profile/Show.vue. This is where users will manage their passkeys. -
If using Jetstream-InertiaJS the below packages are needed are installed automatically if the command was called with the
--jetstream-inertiaoption.- npm i luxon
- npm i @simplewebauthn/browser
Issues
Feel free to raise any Issue here.
Licence
The MIT License (MIT) Copyright © Mathew Paret
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.