Security microservice

We'll create one more service, a security-service, which will control authentication and authorization, and also act as a resource server.

Create a new microservice, security-service, the way other microservices have been created and then follow the following steps:

  1. First, add Spring Security and Spring Security OAuth 2 dependencies in pom.xml:
<dependency> 
   <groupId>org.springframework.cloud</groupId> 
   <artifactId>spring-cloud-starter-security</artifactId> 
</dependency> 
<dependency> 
   <groupId>org.springframework.cloud</groupId> 
   <artifactId>spring-cloud-starter-oauth2</artifactId> 
</dependency> 
  1. Then, we'll create the Spring Boot main application class using @SpringBootApplication. We'll also mark it with @EnableDiscoveryClient ...

Get Mastering Microservices with Java - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.