JSON Web Tokens (JWT)
To authenticate users, we need to store something on the client that identifies the user. Often, this is implemented through a session ID, which is sent via the cookie header. JWT (pronounced jot) works similar—it is also a string that can be sent via a header (or through a URL or POST parameter). However, since JWT does not make use of cookies, it can be easily used across multiple domains.
JWT are JSON objects, which can be signed using a secret key pair (with the HMAC algorithm) or a public/private key pair using RSA. This signature ensures that the tokens do not get forged.
In addition to authentication, JWT also allows for information exchange. For example, we could store information on user roles (is the user an ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access