Cross-cutting pitfalls
This section will cover some of the pitfalls related to various cross-cutting concerns when building microservices, followed by an alternative approach for each.
Embedding security handling inside microservices
Protecting services and allowing secure access to services are some of the primary needs when building services. Embedding the security process for validating an incoming token from a request object into the microservices will be a time-consuming task. Security and token validation can be eradicated from the microservices code, keeping the microservices code clean and tied to its use case. However, if the service does not validate the incoming token, make sure the service is not exposed directly to the consumer without having a front door such as an API gateway. If the service is exposed, it will be vulnerable to attacks and may fail. The solution to this pitfall is by offloading the security to the API gateway.