Open quevlu opened 6 months ago
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
app/jwt.php
3- Replace 'storage' with the previous namespace class
4- Go to app/cache.php
app/cache.php
5- Create a new connection in 'stores'
'jwt' => [ 'driver' => 'redis', 'connection' => 'jwt', 'lock_connection' => 'default', ],
6- Go to app/database.php
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);
This should be implemented out-of-the-box or at least in the documentation! 💪 🔥
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);