Implementing authentication and access control with JWT
In this section, we will demonstrate some practical ways of establishing user authentication and access control. There are many different ways to implement such flows in a microservice environment, among which is JWT, a proposed internet standard for creating security tokens. First, let’s review the basics of the protocol to help you understand how to use it in our microservices.
The basics of JWT
In JWT, security tokens are generated by components that perform authentication or authorization. Each token consists of three parts: a header, a payload, and a signature. The payload is the main part of the token and contains a set of claims – statements about the caller’s identity, such as a user identifier or a role in the system. The following code shows an example of a token payload:
{
"name": "Alexander",
"role": "admin",
"iat"...