This post provides a working example of using Spring Cloud Gateway to decrypt an incoming request from the client, send the decrypted contents to the target service, receive the response and encrypt the response before sending it to the client.
To get hold of the code referred to in this article please visit the repository @ https://github.com/sumantrana/SpringGatewayCustomFilter.git
One of the advantages of using a gateway is that it can be used to handle common functionality that affects multiple routes passing through it e.g. authentication, metrics, encryption/decryption.
Instead of having these common concerns scattered across multiple micro-services, we can consolidate them at the gateway. This provides the following set of advantages:
In this article we will dive deeper into the encryption/decryption aspect. There are a couple of ways in which this functionality can be accomplished:
The following sections explain the latter approach in detail.
#spring-boot #spring-cloud