php - Can Jwt-Auth in laravel handle invalidated tokens in a multi server configuration? -


i have laravel rest api uses tymondesigns/jwt-auth authentication , want scale application single server multi server configuration load balancer in front.

the flow uses refreshtoken middleware , token invalidated after every request , new 1 returned along response. (https://github.com/tymondesigns/jwt-auth/wiki/authentication)

how jwt going manage invalidated tokens in multi server configuration token invalidated using 1 server , new request using invalidated token hit on server?

the right way include jti claim exp , iat claims.

another way (if can) include in token server id (or unique key). can implement server-to-server jwt protocol, think expensive.

another way have sync tokens between servers. use memcached daemon (maybe on front server) maintain list of newly invalidated tokens. if token valid 1 request, memcached receive invalidated token used (maybe right in refreshtoken middleware). based on token timestamp, can decide if token invalid (without going memcached server) or, if it's pretty new, check in memcached list of consumed tokens. memcached have expire time. there many advantages of method (you can use tags, example). if think of list log file, can still did not invalidate stateless principle :)

hope helps.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -