Securing your backend using JWT

In the previous section, we covered how to use basic authentication with the RESTful web service. This method cannot be used when we develop our own frontend with React, so we are going to use JSON Web Token (JWT) authentication instead. JWT is a compact way to implement authentication in modern web applications. JWT is really small in size and can therefore be sent in the URL, in the POST parameter, or inside the header. It also contains all the necessary information pertaining to the user.

The JSON web token contains three different parts, separated by dots:

  • The first part is the header that defines the type of the token and the hashing algorithm.
  • The second part is the payload that, typically, in the case ...

Get Hands-On Full Stack Development with Spring Boot 2 and React - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.