Security is an important part of every web app, and devs must ensure that they design apps with secure authentication. In this tutorial, you’ll learn how to implement JWT-based authentication in Angular apps with the help of a simple Express server.
The full code can be found in our GitHub repo. The app we’ll be building will look like this:
The Concept of JSON Web Tokens
A JSON Web Token (JWT) is basically an object represented by three strings that are used to transmit user information. The three strings, which are separated by dots, are:
When a user logs in to any web page with their username and password, the authenticating server usually creates and sends back a JWT. This JWT is then passed along with subsequent API calls to the server. The JWT remains valid unless it expires or the user signs out of the application.
This process can be illustrated in the diagram below.
Read full tutorial at code.tutsplus