PHPackages                             weldon/laravel-redis-auth - 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. weldon/laravel-redis-auth

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

weldon/laravel-redis-auth
=========================

Laravel authorization and authentication with redis database.

v1.0.0(1y ago)0440MITPHPPHP ^7.4|^8.1

Since Feb 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/weldon-tech/laravel-redis-auth)[ Packagist](https://packagist.org/packages/weldon/laravel-redis-auth)[ RSS](/packages/weldon-laravel-redis-auth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

laravel-redis-auth
==================

[](#laravel-redis-auth)

[![Packagist Dependency Version](https://camo.githubusercontent.com/1025634b59abe4fcb56fb5dbd7e44dc77eaaecfb0df85b512878f8be151e2ed6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f77656c646f6e2f6c61726176656c2d72656469732d617574682f706870)](https://camo.githubusercontent.com/1025634b59abe4fcb56fb5dbd7e44dc77eaaecfb0df85b512878f8be151e2ed6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f77656c646f6e2f6c61726176656c2d72656469732d617574682f706870)[![Total Downloads](https://camo.githubusercontent.com/2d9fd8dc0c1b9127c90d1141594667fb81ea44ebaf794f792821f60d2760d3dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656c646f6e2f6c61726176656c2d72656469732d617574682e737667)](https://camo.githubusercontent.com/2d9fd8dc0c1b9127c90d1141594667fb81ea44ebaf794f792821f60d2760d3dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656c646f6e2f6c61726176656c2d72656469732d617574682e737667)[![Latest Version on Packagist](https://camo.githubusercontent.com/c0b8f85da28d102ea8d258128dfe5f3c8f4660bd71c18434c3060eaa451b846a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656c646f6e2f6c61726176656c2d72656469732d617574682e737667)](https://camo.githubusercontent.com/c0b8f85da28d102ea8d258128dfe5f3c8f4660bd71c18434c3060eaa451b846a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656c646f6e2f6c61726176656c2d72656469732d617574682e737667)[![Packagist License](https://camo.githubusercontent.com/60157acc9759dae7712cb5e5d2aea12f299c7d42095a7042042afa0fc032c236/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656c646f6e2f6c61726176656c2d72656469732d61757468)](https://camo.githubusercontent.com/60157acc9759dae7712cb5e5d2aea12f299c7d42095a7042042afa0fc032c236/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656c646f6e2f6c61726176656c2d72656469732d61757468)

The Laravel Redis Auth Package is a Composer package that provides authentication functionality using a Redis database in Laravel applications. It offers a seamless integration with Laravel's authentication system while leveraging the speed and flexibility of Redis for storing user credentials.

Purpose
-------

[](#purpose)

I wanted to build microservices and I realized that I need a authentication service which can works with all microservices. Then I had created this package. If you have three microservices, you should install this package to your all of them and you should connect services to one Redis database. When client sends request to get new access token, one of your services creates access token and stores it to Redis database. When client sends request to other service with acces token, that service can check token from Redis database.

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

[](#requirements)

- PHP &gt;= 7.4
- predis/predis
- Redis database

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

[](#installation)

Install the package via Composer:

```
composer require weldon/laravel-redis-auth
```

Publish
-------

[](#publish)

Publish the package configuration:

```
php artisan vendor:publish --provider="Weldon\LaravelRedisAuth\RedisAuthServiceProvider"
```

Usage
-----

[](#usage)

Update the `.env` configuration to use the cache for authentication:

```
REDIS_CLIENT=predis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

REDIS_PREFIX=''
```

You must add `Weldon\LaravelRedisAuth\Traits\RedisAuthentication` trait to you `App/Models/User` class.

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Weldon\LaravelRedisAuth\Traits\RedisAuthentication;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable, RedisAuthentication;

    ...
```

After that you can create access token by `createAuthToken` function of `App/Models/User` class. You can create token with abilities. The packge stored all tokens with abilities in Redis database.

```
$user = User::query()
    ->where('email', $request->string('email'))
    ->first();

$accessToken = $user->createAuthToken([
    'users.add',
    'users.show',
    'users.delete',
]);
```

You can check token's ability with `check` function of `App/Models/User` class in your Controllers. If user does not have a ability, `check` function throw `Illuminate/Http/Exceptions/HttpResponseException`.

```
Auth::user()->check('users.add', "If you want to change error message!");

OR

auth()->user()->check('messages.show');
```

You can protect your routes by adding the auth middleware to them:

```
Route::middleware('redis-auth')->group(function () {
    // Protected routes
});
```

There are configurations in `redis-auth.php` in `config` folder. You can change them.

```
    /**
     * Name of redis connection.
     *
     * Note that this name is listed in the redis section of your config/database.php
     */
    'connection' => env('REDIS_AUTH_CONNECTION', 'default'),

    /**
     * Name of selected hashing algorithm (i.e. "md5", "sha256", "haval160,4", etc..)
     * See hash_algos for a list of supported algorithms.
     */
    'algo' => env('REDIS_AUTH_ALGO', 'sha256'),

    /**
     * Secret key for creating a new token
     */
    'secret_key' => env('REDIS_AUTH_SECRET_KEY', 'laravel-redis-auth-secret-key'),

    /**
     * token_ttl represents the Token Time To Live, which defines the lifespan or expiration time of a token.
     */
    'token_ttl' => env('REDIS_AUTH_TOKEN_TTL', 3600 * 24),

    /**
     */
    'unauthorized_message' => env('UNAUTHORIZED_MESSAGE', 'Unauthorized...'),
```

Contributing
------------

[](#contributing)

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License
-------

[](#license)

This package is open-source and released under the MIT License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance43

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

452d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3287e990c6a21e337bdb915cd5547c35a4a5dfad1322bc639479ffaaaa41765?d=identicon)[weldon-tech](/maintainers/weldon-tech)

---

Top Contributors

[![asrorbek-mannonov](https://avatars.githubusercontent.com/u/44311347?v=4)](https://github.com/asrorbek-mannonov "asrorbek-mannonov (1 commits)")

---

Tags

laravelauthredis

### Embed Badge

![Health badge](/badges/weldon-laravel-redis-auth/health.svg)

```
[![Health](https://phpackages.com/badges/weldon-laravel-redis-auth/health.svg)](https://phpackages.com/packages/weldon-laravel-redis-auth)
```

###  Alternatives

[orchestra/auth

Auth Component for Orchestra Platform

24108.5k3](/packages/orchestra-auth)[codebot/entrust

This package provides a flexible way to add Role-based Permissions to Laravel

1596.6k](/packages/codebot-entrust)[ingria/laravel-x509-auth

Laravel 5 Client Certificate auth middleware

375.6k](/packages/ingria-laravel-x509-auth)[setiawanhu/sanctum-auth

Laravel package for generating user authentication feature using Laravel Sanctum

132.8k](/packages/setiawanhu-sanctum-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
