In this section, we are going to add Roles to the authorities.

We need to create a new class, this Class is used to extract the Roles from the JWT token and place them in the Authorities of the user.

SecurityConfig must be modified,
We create 3 users with Roles.
Configure 3 new endpoints.
Configure the CustomJwtAuthenticationConverter.

HomeController needs to be modified with 3 additional endpoints.

TokenService we need to modify to properly handle the Roles in the JwtToken.

Now we can start the project and test it out with Insomnia or Postman.

You can find the code on Gihub.

Youtube

Next part.

--

--