Invalidating JSON Web Tokens

前端 未结 28 2396
夕颜
夕颜 2020-11-22 06:17

For a new node.js project I\'m working on, I\'m thinking about switching over from a cookie based session approach (by this, I mean, storing an id to a key-value store conta

28条回答
  •  北海茫月
    2020-11-22 06:59

    I would keep a record of the jwt version number on the user model. New jwt tokens would set their version to this.

    When you validate the jwt, simply check that it has a version number equal to the users current jwt version.

    Any time you want to invalidate old jwts, just bump the users jwt version number.

提交回复
热议问题