Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis connection to store blacklisted jwts #2254

Open
quevlu opened this issue Apr 16, 2024 · 1 comment
Open

Redis connection to store blacklisted jwts #2254

quevlu opened this issue Apr 16, 2024 · 1 comment

Comments

@quevlu
Copy link

quevlu commented Apr 16, 2024

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);

@WendellAdriel
Copy link

This should be implemented out-of-the-box or at least in the documentation! 💪 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants