api-gatewaykrakend

How to protect internal routes from external use in Krakend?


The problem is that there are too many requests due to the fact that we have to use internal authorization between microservices.

There is very little information about Krakend and there are no articles about the experience of using Krakend. Reading the documentation didn't work either.


Solution

  • If I understood your questions correctly, you're trying to protect some "internal" routes intended to be consumed just from your microservices from external usage. Here's how you could do it with KrakenD:

    Using Separate Gateways: The simplest approach would be to have separate gateways for external and internal requests. The external routes could be open to the outside, while the internal ones would be behind a firewall or in a private network, accessible only from your microservices.

    Adding some validation to internal resources: If you prefer to have a single gateway for both external and internal requests, you could add protection to internal routes/endpoints. This could be achieved through authentication or header validation implemented with Common Expression Language (CEL), Security Policies, or LUA scripting.

    Filtering origin IPs: Another way to protect access to some routes for internal usage is by using the IP filter component. This allows you to define which IPs can access certain endpoints. You can find more about it here: https://www.krakend.io/docs/enterprise/throttling/ipfilter/

    I hope this helps!