Example of a minimally configured Netflix (Zuul) reverse proxy as implemented by Spring Security and Spring Boot
Key concepts being demonstrated are:
- Reverse Proxy functionality in a microservice environment. Currently, this server forwards only to the server defined in rsw-product, a sample microservice
- Composite Swagger API presentation, using the springfox Swagger implementation and a bit of custom code, the gateway hosts a list of Swagger API sets for the chosen proxied microservices. This is accessible at localhost:8080/swagger-ui.html
- OAuth2 security with both a Resource Server (oauth2 client) role, and an SSO role to ensure tokens are propagated to the
downstream services
- As an OAuth2 client, there are three separate Spring profiles that invoke different configurations
to demonstrate the following variations:
- profile = github :: Uses Github.com as the Authorization Server, using an authorized OAuth2 application on my Github account. These are OAuth2 tokens.
- profile = rossoauth2 :: Uses the rsw-auth repo's Auth Server implementation, set for OAuth2 tokens See rsw-auth for details, as this setting depends on the Auth Server's property settings for oauth2
- profile = rossjwt :: Uses the rsw-auth repo's Auth Server implementation, set for JWT tokens See rsw-auth for details, as this setting depends on the Auth Server's property settings for jwt
- Note that corresponding profile settings are required in the downstream rsw-product service for everything to work properly
- As an SSO provider, tokens are provided to the downstream services with minimal configuration using Spring
- Downstream services are automatically provided with the Github OAuth2 token in the request header
- Downstream services use @EnableResourceServer to automatically setup security using the proxy-provided token
- The downstream Resource Server services, when using OAuth2 tokens, invoke the userInfoUri to fetch user details and set the Spring Security context.
- As an OAuth2 client, there are three separate Spring profiles that invoke different configurations
to demonstrate the following variations:
The Github authentication produces a single Authority, ROLE_USER. However, a minor customization of the AuthoritiesExtractor is provided as an example in the rsw-product repo ExternalOAuthConfig