PHPackages                             qisthidev/laravel-auth-device - 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. qisthidev/laravel-auth-device

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

qisthidev/laravel-auth-device
=============================

Laravel package for device-based authentication. Users authenticate using registered devices without passwords and access is granted through admin invitations.

00PHPCI passing

Since Dec 3Pushed 7mo agoCompare

[ Source](https://github.com/qisthidev/laravel-auth-device)[ Packagist](https://packagist.org/packages/qisthidev/laravel-auth-device)[ RSS](/packages/qisthidev-laravel-auth-device/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Auth Device
===================

[](#laravel-auth-device)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5bab75e9486968af446f419865d5f6706b297cdae9b2aa0561a3a6dcac8b795f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7169737468696465762f6c61726176656c2d617574682d6465766963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/qisthidev/laravel-auth-device)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c8482d5d96fc1e16470171b89f4e87c00d1c8fc347a4f5c0676f7642e282ee13/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7169737468696465762f6c61726176656c2d617574682d6465766963652f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/qisthidev/laravel-auth-device/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/75e84785a5a1a936727a53a13a5cdb8184ebb084724e40cf77b674108081c581/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7169737468696465762f6c61726176656c2d617574682d6465766963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/qisthidev/laravel-auth-device)

A Laravel package for device-based authentication. Users authenticate using registered devices (without passwords) and access is granted through admin invitations.

Features
--------

[](#features)

- **Device-based Authentication**: Authenticate users via registered devices using unique device tokens
- **Invitation System**: Admin users can invite new users via email
- **Device Management**: Users can manage their registered devices
- **Custom Guard**: Dedicated authentication guard for device-based auth
- **Flexible Configuration**: Customizable token lengths, expiry times, and more
- **Event System**: Events for all major actions (device registered, authenticated, revoked, etc.)

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

[](#requirements)

- PHP 8.2+
- Laravel 12.x

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

[](#installation)

Install the package via Composer:

```
composer require qisthidev/laravel-auth-device
```

Publish and run the migrations:

```
php artisan vendor:publish --provider="Qisthidev\AuthDevice\AuthDeviceServiceProvider" --tag="auth-device-migrations"
php artisan migrate
```

Publish the config file:

```
php artisan vendor:publish --provider="Qisthidev\AuthDevice\AuthDeviceServiceProvider" --tag="auth-device-config"
```

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

[](#configuration)

The config file `config/auth-device.php` contains the following options:

```
return [
    // Device token settings
    'device_token_length' => 64,
    'device_token_expiry_days' => 365, // null for no expiry

    // Invitation settings
    'invitation_code_length' => 8,
    'invitation_expiry_hours' => 48,

    // Security settings
    'max_devices_per_user' => 5, // null for unlimited
    'require_device_verification' => false,

    // Routes
    'route_prefix' => 'api/auth',
    'route_middleware' => ['api'],

    // Models (allow customization)
    'models' => [
        'user' => 'App\\Models\\User',
        'device' => Qisthidev\AuthDevice\Models\Device::class,
        'invitation' => Qisthidev\AuthDevice\Models\Invitation::class,
    ],

    // Table names
    'tables' => [
        'devices' => 'auth_devices',
        'invitations' => 'auth_invitations',
    ],
];
```

Auth Guard Configuration
------------------------

[](#auth-guard-configuration)

Add the device guard to your `config/auth.php`:

```
'guards' => [
    // ... other guards
    'device' => [
        'driver' => 'device',
        'provider' => 'device',
    ],
],

'providers' => [
    // ... other providers
    'device' => [
        'driver' => 'device',
    ],
],
```

Setting Up Your User Model
--------------------------

[](#setting-up-your-user-model)

Add the required traits to your User model:

```
