jwt-auth icon indicating copy to clipboard operation
jwt-auth copied to clipboard

Redis connection to store blacklisted jwts

Open quevlu opened this issue 10 months ago • 1 comments

This is an example to store blacklisted jwts on Redis.

1- Create a new class with this content

`<?php

namespace Infrastructure\Redis\Jwt;

use Illuminate\Support\Facades\Cache; use Tymon\JWTAuth\Providers\Storage\Illuminate;

class Storage extends Illuminate { public function __construct() { $this->cache = Cache::store('jwt'); } }`

2- Go to app/jwt.php

3- Replace 'storage' with the previous namespace class

4- Go to app/cache.php

5- Create a new connection in 'stores'

'jwt' => [ 'driver' => 'redis', 'connection' => 'jwt', 'lock_connection' => 'default', ],

6- Go to app/database.php

7- Save a new connection in 'redis'

'jwt' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST'), 'username' => env('REDIS_USERNAME'), 'password' => env('REDIS_PASSWORD'), 'port' => env('REDIS_PORT'), 'database' => '2', // You can select a specific database ],

8- You should call auth()->logout(true);

quevlu avatar Apr 16 '24 13:04 quevlu