JWT Authorization in Microservices with Spring boot

Viewed 3168

I have to build an application by using microservice architecture. I divided the whole system into multiple components and each component represents a spring boot project. There are several spring boot projects around 6. I have used the eureka server to register all the services for load balancing. A separate Spring boot project has been developed for the web portal and that application contains authentication, authorization with spring security, and JWT protocol. Now I have 7 projects including a web portal and each project has controller classes under the controller's package.

Now I need to know the following things,

  1. SignUp and SignIn request come to the web portal and after signing a JWT token is generated and it is sent to the client but the Authorization part is only available in the SecurityConfig class on the web portal. So should I send all the requests from the client to a component through the web portal each and every time after authenticated?

         Client ----------------> Web Portal ------------------>Service/Component
    

I need to know that can I send a request to another component/service directly like below?

                  username + password
   Client --------------------------------------->  Web Portal

                     JWT token
   Client <-------------------------------------- Web Portal
            
                    JWT token
   Client ------------------------------------------> Service/Component
1 Answers

likely yes, because JWT is something available with the user and every time he sends the request, the token shall be validated by the issuer or in cases when we black list some tokens then those requests shall not be processes directly.

In microservices, the API gateways take care of these things and after checking for role and permissions, it forwards the request to the respective microservices based on the incoming route or URI which is then mapped to URI of backend service registered in Eureka server.

Related