New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

hungdx/auth-token

The Authentication driver using token for Laravel Framework.
2,672

Larablocks Analysis

hungdx/auth-token works with Laravel 5 to 8 (latest release 1.0.3, Jan 20, 2021), all past end of life (the last on Jan 24, 2023): no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 5 to 8, past end of life since Jan 24, 2023
  • No release in the last 12 months (last: Jan 20, 2021)
  • 0 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Jan 20, 2021.
  • No releases in the last 12 months.
  • First released: Dec 24, 2020.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 29, 2026.

Install
composer require hungdx/auth-token
Latest Version:1.0.3
PHP:^7.1.3|^8
Laravel:5 – 8
License:MIT
Last Updated:Feb 3, 2021
Links: GitHub  ·  Packagist
Maintainer: hungdx

Laravel Auth-Token

Driver for Laravel Auth by using tokens

The story

We need a way to authenticate for web and api. Laravel supports drivers session (SessionGuard), token (TokenGuard), request (RequestGuard) but it is not strong enough.

  • SessionGuard: Unable use for api. On the Web, with the same user and remember is on -> only one device can use this feature.
  • TokenGuard: It is not designed for Web and not supported multiple device login at sametime
  • RequestGuard: Not checked yet

For api, we have got JWT, why not use that?

JWT very easy to create and verify tokens, but it is not strong enough to manage the tokens. When you want to remove a token which was created before, no way to do that until the token expires.

What do the features of this driver?

  • Supported for web, api or any other purposes.
  • Support multiple devices login for a user at sametime.
  • With a good config, we can count number users/devices of user are logged-in (Set refresh lifetime to small enough and count records in the table user_tokens)
  • All tokens stored in the database. To logout a device, just delete the token record of this device.
Required:
"php": "^7.1.3|^8",
"laravel/framework": "^5.8|^6|^7|^8"

Installation

Require this package with composer
composer require hungdx/auth-token

Laravel

Add the AuthTokenProvider to the providers array in config/app.php

HungDX\AuthToken\AuthTokenProvider::class,

Create user_tokens table

php artisan migrate --path="vendor/hungdx/auth-token/migrations"

Lumen

For Lumen, register a different Provider in bootstrap/app.php:

$app->register(HungDX\AuthToken\AuthTokenProvider::class);

To change the configuration, copy the file to your config folder and enable it:

$app->configure('auth-token');
Create user_tokens table
php artisan migrate --path="vendor/hungdx/auth-token/migrations"

Usage

In the bootstrap/auth.php, at guards section, change driver to auth-token. For example:

    'guards' => [
        'web' => [
            'driver'   => 'auth-token',
            'provider' => 'users',
        ],

        'api' => [
            'driver'   => 'auth-token',
            'provider' => 'users',
        ],
    ],

Configuration

If you want to customize the config, run command:

php artisan vendor:publish --provider="HungDX\AuthToken\AuthTokenProvider"

File config/auth-token.php

return [
    'lifetime' => [
        'expired' => 7 * 24 * 3600,  // Lifetime of token before expired. Default 7 days
        'refresh' => 3600,           // The minimum seconds before changing the token. Default 1 hour
    ],

    'token_field' => [
        'header' => 'Authorization', // Set [false/null/empty] to disable send token to response header  
        'cookie' => 'X-Auth-Token',  // Set [false/null/empty] to disable send token to response cookie
    ],

    'autoload_middleware' => true,  // Auto add to middleware HungDX\AuthToken\AuthTokenMiddleware to every request
];

Changes

1.0.3 (2021-01-20)
  • Fix migration in Laravel 5.8
1.0.2 (2020-12-30)
  • Support PHP 7.1.3, Laravel 5.8
1.0.1 (2020-12-25)
  • Support remember flag. When remember is on, The token never expire until logged out
  • Support PHP 7.2
  • Fix phpcs
  • Fix migration
1.0.0 (2020-12-24)
  • Add auth-token driver for Auth of laravel/lumen
  • Auto add middleware to all router groups

Related Packages

intervention/httpauth

HTTP Authentication Management for PHP

14,803,824 83
custom-d/api-authentication

A api authentication

11,627
nachofassini/laravel-ext-auth

Extend laravel default authentication

15 0
kalfheim/session-tokens

Unique, revokable "remember me" tokens for Laravel

7 0
dvsa/authentication-ldap

A wrapper around LDAP

17,120 0

Version History

Version Released PHP Laravel License
1.0.3 ^7.1.3|^8 ^5.8|^6|^7|^8 MIT
1.0.2 ^7.1.3|^8 ^5.8|^6|^7|^8 MIT
1.0.1 ^7.2|^8 ^6|^7|^8 MIT
1.0.0 ^7.3|^8 ^6|^7|^8