tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.31k stars 1.54k forks source link

Make cache instance / blacklist storage configurable #1672

Open thlassche opened 6 years ago

thlassche commented 6 years ago

Make cache instance / blacklist storage configurable

Because the token blacklist is stored in the default laravel cache instance, the blacklist is cleared every time the cache is cleared. Would be better to make the cache instance configurable, just like Laravel did it for the session and cache instances: https://github.com/laravel/laravel/commit/c3b99e971cd9d8213ada259b9f624a8f70ddd57b#diff-ef16cabd572189f548df70d3f0042c33

Your environment

Q A
Bug? yes
New Feature? yes
Framework Laravel
Framework version 5.7.3
Package version 1.0.0-rc-3
PHP version 7.1

Steps to reproduce

Expected behaviour

The invalidated token should never work again

Actual behaviour

The invalidated token started working again

miki131 commented 6 years ago

You can use contextual binding

$this->app
    ->when(\Tymon\JWTAuth\Providers\Storage\Illuminate::class)
    ->needs(\Illuminate\Contracts\Cache\Repository::class)
    ->give(function () {
        return cache()->store('jwt');
    });
thlassche commented 6 years ago

@miki131 Great, thanks. That will do the job for now for me.