Authentication: JWT usage vs session

前端 未结 4 1933
无人共我
无人共我 2020-11-30 16:17

What is the advantage of using JWTs over sessions in situations like authentication?

Is it used as a standalone approach or is it used in the session?

4条回答
  •  难免孤独
    2020-11-30 16:46

    The short answer is: None.

    A longer version is:

    I implemented JWTs for session management after reading this recommendation in the GraphQL docs:

    If you aren't familiar with any of these authentication mechanisms, we recommend using express-jwt because it's simple without sacrificing any future flexibility.

    Implementation was indeed simple as it only added a little bit of complexity. After a while however, I (like you) started wondering what the benefits were. It turns out there are very few (or possibly none) for JWT as far as session management goes, as this blog post explains in detail:

    Stop using JWT for sessions

提交回复
热议问题