OAuth 2.0 is a way of securing APIs. Spring Security provides Spring Cloud Security and Spring Cloud OAuth2 components for implementing the grant flows we discussed earlier.
We'll create one more service, a security-service, which will control authentication and authorization.
Create a new Maven project and follow these steps:
- Add the 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>
- Use the @EnableResourceServer annotation in your application class. This will allow this...