9 Securing your microservices
This chapter covers
- Learning why security matters in a microservice environment
- Understanding the OAuth2 standard
- Setting up and configuring a Spring-based OAuth2 service
- Performing user authentication and authorization with OAuth2
- Protecting your Spring microservice using OAuth2
- Propagating your OAuth2 access token between services
Now that we already have a robust microservices architecture, the task of covering security vulnerabilities becomes more and more urgent and essential. In this chapter, security and vulnerability are two topics that go by the hand. We'll define vulnerability as a weakness or flaw presented in an application. Of course, all systems have vulnerabilities, but the big difference lies in whether or not these vulnerabilities are exploited to cause harm. On the other hand, security, the mention of this word, will often cause an involuntary groan from the developer who hears it. Sometimes among developers, we have heard comments such as "It's obtuse, hard to understand, and even harder to debug." Yet we won't find any developer (except maybe for inexperienced developers) say that that they don't worry about security.
Before we start it is essential to highlight that securing a microservices architecture is a complex and laborious task and it involves multiple layers of protection, including: