A high-performance, stateless API Gateway built with Spring Cloud Gateway and Spring WebFlux. This project acts as the security perimeter for a microservices architecture, implementing JWT-based authentication at the edge.
- Edge Authentication: Centralized JWT validation using a custom
GatewayFilter. - Reactive Architecture: Built on Project Reactor (Netty) for non-blocking, high-concurrency request handling.
- Stateless Security: Configured with
Spring Securityto be fully stateless (no sessions/cookies). - Dynamic Routing: Decouples client requests from internal microservice locations.
The Gateway acts as a "Reverse Proxy." Every request must pass through a security filter chain before being routed to the downstream services (e.g., Order Service).
- Java 17
- Spring Boot 3.2.5
- Spring Cloud 2023.0.0 (Leyton Release Train)
- jjwt (Java JWT) for digital signature verification.
- Intercept: The
AuthenticationFilterintercepts theAuthorizationheader. - Validate:
JwtUtilsre-calculates the HMAC-SHA signature using a shared secret. - Route: If valid, the request is proxied to the target microservice defined in
application.yml. - Reject: Invalid or missing tokens receive a
401 Unauthorizedresponse immediately.
- Clone the repository.
- Ensure your Order Service (or any backend) is running on
http://localhost:8080. - Run the gateway:
./mvnw spring-boot:run