Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Security issue in microservices with Spring Boot

I have misunderstanding security in microservices in spring boot (and general). I want to build a project using Spring framework and microservices but in architecture planning I stuck. How should be security in microservices at all? In my opinion that in all project should be one component which all request go throw the component and spread to other components. What I could find it's Spring Cloud Zuul which is api gateway in microservices and I got idea to make a project which is response for gateway and add security in the component as well. I mean it will be something like a project that contains Spring Cloud Zuul, Spring Security, Spring Data JPA dependencies. How do you think is it good way to provide a security or not? Is it possible to build something like that?

like image 428
Dave Avatar asked Jan 04 '23 08:01

Dave


2 Answers

In the project I was involved, we used security at a couple of different levels:

  • Security at individual route level in Zuul.
  • Security at each internal service

Here is the flowchart for the security model used in our Spring Cloud project,

  1. When Zuul receives a request, it checks if a route exists for the request.
  2. If a route exists, checks if the route is secured based on custom configuration.
  3. If the route is secured, authenticates the request.
  4. Once the request is authenticated at Zuul, Zuul again checks if the internal service, to which request is to be routed, is secured based on configuration.
  5. If the internal service is secured, creates a new Authentication header based on the user credentials (stored in the custom configuration) before routing the service to the internal service.
  6. Once the internal service receives the request from Zuul, it checks if the request needs to be authenticated.
  7. Once authenticated, processes the request and sends the response back.
like image 187
Indra Basak Avatar answered Jan 06 '23 01:01

Indra Basak


I think the answer here might help you, they are talking about using firewall to limit the access from the outbound IP and only allow zuul gateway to access all microservice.

Don't allow direct calls to Microservices. Only allow through API Gateway

like image 39
Chi Dov Avatar answered Jan 06 '23 02:01

Chi Dov