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:
- 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>
- Then, we'll create the Spring Boot main application class using @SpringBootApplication. We'll also mark it with @EnableDiscoveryClient ...