How jihedchaabane/gr-client-credentials-demo works
This repository is a Spring-based OAuth2 client-credentials and service-to-service demo, with separate authorization, gateway, client, and infrastructure applications. The demonstrated workflow is an HTTP caller invoking the RestTemplate consumer, which obtains a token from the authorization server and calls the gateway; client1 can also call client2 directly. The tree documents additional config-server, Eureka, and Spring Boot Admin services, but the supplied excerpts do not establish their runtime connections or gateway routing, so those links are omitted.
Main entry points: Ms3Controller.java Token Consumer · AuthorizationServerConfig.java OAuth2 Server · ProtectedController.java Client One · TokenResponse.java Token Response
Components 17
Authorization
- OAuth2 Server
gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/AuthorizationServerConfig.java - Auth Security
gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/SecurityConfig.java - User Validation
gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/ValidateUserController.java - Auth Hello API
gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/HelloController.java
Service Clients
- Token Consumer
springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java - Token Response
springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/model/TokenResponse.java - Client One
springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java - Client One Security
springboot-oauth2-client1/src/main/java/com/chj/gr/conf/SecurityConfig.java - Public API
springboot-oauth2-client1/src/main/java/com/chj/gr/controller/PublicController.java - Client Two
springboot-oauth2-client2/src/main/java/com/chj/gr/controller/Protected2Controller.java - Client Two Security
springboot-oauth2-client2/src/main/java/com/chj/gr/conf/SecurityConfig.java
Gateway Access
- API Gateway
gr-conf-api-gateway/src/main/java/com/chj/gr/ApiGatewayApplication.java - Gateway Security
gr-conf-api-gateway/src/main/java/com/chj/gr/conf/SecurityConfig.java
Platform Services
- Config Server
gr-conf-config-server/src/main/java/com/chj/gr/SpringConfigServerApplication.java - Service Registry
gr-conf-eureka-server/src/main/java/com/chj/gr/EurekaServerApplication.java - Service Admin
gr-conf-springboot-admin/src/main/java/com/chj/gr/SpringBootAdminApplication.java
Other components
- HTTP Caller
Connections 6
- HTTP Caller → Token Consumer: invokes
springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java - Token Consumer → OAuth2 Server: requests token
springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java - OAuth2 Server → Token Consumer: returns token
springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java - Token Consumer → Token Response: maps response
springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java - Token Consumer → API Gateway: calls API
springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java - Client One → Client Two: calls endpoint
springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java