Coder Social home page Coder Social logo

Comments (4)

amir-khoshbakht avatar amir-khoshbakht commented on June 7, 2024

It also breaks the logout functionality

from jwt-auth.

amir-khoshbakht avatar amir-khoshbakht commented on June 7, 2024

..... the "diffInRealMinutes" Carbon method is used, I didn't find it anywhere in Carbon's actual Doc
https://github.com/briannesbitt/Carbon/blob/34ccf6f6b49c915421c7886c88c0cb77f3ebbfd2/src/Carbon/Traits/Date.php#L2595

the "diffInRealMinutes" is the same as "diffInMinutes"

from jwt-auth.

elhannaoui-ayoub avatar elhannaoui-ayoub commented on June 7, 2024

please how does the token invalidate works , do we store them in a table of balcklists or what?

from jwt-auth.

francsiswanto avatar francsiswanto commented on June 7, 2024

This is my solution and it's work.

  • Create some providers to override existing Tymon\JWTAuth\Providers\Storage\Illuminate, let say name it as 'App\Storage\JWTStorage'. See script below.
  • Publish jwt configuration
  • Edit config/jwt.php and replace 'providers' as
(-) 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
(+) 'storage' => App\Storage\JWTStorage::class,

App\Storage\JWTStorage.php script:

namespace App\Storage;

use Tymon\JWTAuth\Providers\Storage\Illuminate;

class JWTStorage extends Illuminate {
    public function add($key, $value, $minutes) {
        parent::add($key, $value, abs($minutes));
    }
}

Since blacklisting/invalidating using cache mechanism, then artisan cache:clear will erase all blacklist entries. To avoid it, we can tweak above script to targeting into another store (example 'redis_blacklist'):

use Illuminate\Contracts\Cache\Repository as CacheContract;
use Tymon\JWTAuth\Providers\Storage\Illuminate;

class JWTStorageProvider extends Illuminate {
    protected $cache;

    public function __construct(CacheContract $cache) {
        $this->cache = cache()->store('redis_blacklist');
    }

    public function add($key, $value, $minutes) {
        parent::add($key, $value, abs($minutes));
    }
}

of course the solution above is better solved by jwt-auth, including changing the use of blacklist storage with config/jwt.php.

Just simply do the best, hoping for the best and let God take the rest.

from jwt-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.