Node.js api gateway implementation and passport authentication

I am working on a microservice-based application using node.js. While searching for examples on how to implement the api gateway, I came across the following article, which seems to serve as an example of the implementation of the api gateway: https://memz.co/api-gateway-microservices-docker-node-js/ . Although finding an example for implementing the api gateway template in node.js seems a bit difficult to do so far, this article seemed like a really good example.

There are a few points that are still unclear, and I still have problems finding the document. on the.

1) Security is an important element for the application. I'm developing, I have problems with where the authentication should occur (for example, using a passport, should I add authentication elements to the api gateway and transfer the jwt token along with the request for the corresponding microservice, since the information registered by the user is necessary for certain types of activities The only problem here is that for all microservices you will need a passport to decrypt the jwt token in order to get user profile information. and microservice is technically inaccessible to the outside world, except through an api-gateway, how does this seem to be the goal?

2) How does this scenario change if I need to scale to several servers with docker images on each of them? How will this affect load balancing because it seems like something would have to sit at a higher level to handle load balancing?

+4
source share
1 answer

I can say that a lot depends on your application requirements. Indeed. I have already gone through 5 years of experience working with microservices that use several languages, starting with a medium to very large scale system.

, , , , (), , , , , .

, , . , - - ( ) .

edge newtwork (, Gateway API). , , :

  • Gateway API, , , , - , , ( JSON, " " ). , , .

  • , ( ) ( ), ( , , , , , ). , , , , ( , , , ).

: (jwt, jwe , , ).

JWT , , , (, , , , 2FA ). JWE - . ( ) , cookie-, .

: , .

, , , REST, RPC, IPC, , .

, - , , API-, . , ( , ) , .

, , , , . , , , ( ).

, , . , 25 , , - : API, , , , - A N, ( ), ( ), .

, , , . , , , , , .

, : . , :

  • API Gateway ( N , , , API IP- HAproxy , , - IP- API ).

  • ( API), . # 1

  • ( API), - : ( 3 7) DNS, DNS, IP-, , Anycast, .

, , . , , SLOC , .

, , .

, , . , , , .

P.S. API, . , - .

!

+6

Source: https://habr.com/ru/post/1673249/


All Articles