abdulwahhabkhan / device-auth-livewire
Livewire + Alpine frontend for abdulwahhabkhan/device-auth: device verification, confirmation and the device admin screens.
Package info
github.com/abdulwahhabkhan/device-auth-livewire
Language:Blade
pkg:composer/abdulwahhabkhan/device-auth-livewire
Requires
- php: ^8.3
- abdulwahhabkhan/device-auth: ^0.2
- laravel/framework: ^13.0
- livewire/livewire: ^3.6|^4.0
Requires (Dev)
- driftingly/rector-laravel: ^2.0
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^12.0
- rector/rector: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Livewire + Alpine screens for abdulwahhabkhan/device-auth: only approved devices can use your Laravel app, each proving itself with a passkey (WebAuthn) stored on the device.
The core package holds all the logic (actions, routes, middleware, WebAuthn). This package only draws the pages:
| Screen | Route | Component |
|---|---|---|
| Verify this device / request access | device-auth.verify |
device-auth.verify |
| Confirm this device | device-auth.confirm |
device-auth.confirm |
| Device list | device-auth.admin.index |
device-auth.admin.device-index |
| Device details, approve / reject / revoke | device-auth.admin.show |
device-auth.admin.device-show |
Pages use plain Tailwind utilities (neutral palette with dark: variants) and look the same as the React package.
Requirements
PHP 8.3+, Laravel 13, Livewire 3.6+ or 4, Tailwind CSS. WebAuthn needs https (or localhost).
Installation
composer require abdulwahhabkhan/device-auth abdulwahhabkhan/device-auth-livewire php artisan device-auth:install # core: config, actions, service provider php artisan device-auth:livewire-install # this package: config (add --views to edit the Blade views) php artisan migrate
Tell Tailwind about the package views, in resources/css/app.css (Tailwind 4):
@source '../../vendor/abdulwahhabkhan/device-auth-livewire/resources/views';
Then npm run build. The browser script ships prebuilt; nothing is added to your JavaScript.
Protect routes as described in the core README:
Route::middleware(['auth', 'device.verified'])->group(function () { Route::view('dashboard', 'dashboard')->name('dashboard'); });
Layouts
config/device-auth-livewire.php:
'layout' => 'device-auth::layouts.guest', // verify + confirm: full-screen, no app chrome 'admin_layout' => 'layouts.app', // device admin: your app layout, e.g. <x-layouts.app> 'vite' => ['resources/css/app.css'], // loaded by the package layouts
Each value is a Blade component name. Layouts receive a title attribute.
Confirming the device in your own components
The device.confirm middleware protects routes. For Livewire actions use the trait, which asks the browser to confirm and then replays the call:
use AbdulWahhabKhan\DeviceAuth\Livewire\Components\Concerns\ConfirmsDevice; class Payroll extends Component { use ConfirmsDevice; public function export(): void { if (! $this->deviceConfirmed('export')) { return; // the confirm dialog opens; export() runs again once the device is confirmed } // … } }
Render the dialog once on the page:
<x-device-auth::confirm-modal />
Customising
- Behaviour: change the published core actions in
app/Actions/DeviceAuth. The Livewire screens call the same actions. - Markup:
php artisan vendor:publish --tag=device-auth-livewire-viewscopies the views toresources/views/vendor/device-auth. - Component classes:
php artisan vendor:publish --tag=device-auth-livewire-componentscopies subclasses toapp/Livewire/DeviceAuth. Pointcomponentsin the config at them. - Text: core messages come from
lang/vendor/device-auth(--tag=device-auth-lang).
| Publish tag | Files |
|---|---|
device-auth-livewire-config |
config/device-auth-livewire.php |
device-auth-livewire-views |
resources/views/vendor/device-auth |
device-auth-livewire-components |
app/Livewire/DeviceAuth |
Security notes
- Admin components check the
manage-device-authgate and a verified device on every request, including Livewire updates. - The package registers
device.verifiedanddevice.confirmas Livewire persistent middleware, so updates to a component on a protected page are checked like the page itself. - Approve / reject / revoke require a recent device confirmation (default 10 minutes,
device-auth.confirm_timeout).
Development
composer install composer test # pint --test, rector --dry-run, phpstan (level 7), phpunit npm install npm run types # tsc --noEmit (strict) npm run build # rebuilds dist/device-auth.js, commit the result
Developing against a local core
The package installs abdulwahhabkhan/device-auth from Packagist. To work on both side by side, point Composer at your checkout (don't commit this):
composer config repositories.core '{"type": "path", "url": "../laravel-device-auth", "options": {"versions": {"abdulwahhabkhan/device-auth": "0.2.0"}}}'
composer update abdulwahhabkhan/device-auth
License
MIT. See LICENSE.