A production-ready API Gateway and Authentication Service solution for microservices architecture, designed to be technology-agnostic and scalable.
βββββββββββββββββββ
β Client Apps β
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Kong Gateway β
β (Entry Point) β
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Spring Cloud β
β Gateway β
β (Custom Logic) β
ββββββββββ¬βββββββββ
β
ββββββββββββββββββββββΌβββββββββββββββββββββ
β β β
βββββββΌββββββ βββββββββΌββββββββ ββββββββΌβββββββ
β Auth β β Microservice 1 β βMicroservice 2β
β Service β β (Example) β β (Example) β
βββββββββββββ ββββββββββββββββββ βββββββββββββββ
β
β
βββββββΌββββββ ββββββββββββββββ
β Redis β β Eureka β
β (Cache) β β (Discovery) β
βββββββββββββ ββββββββββββββββ
- Kong Gateway: Primary entry point with plugins for JWT validation, rate limiting, IP filtering
- Spring Cloud Gateway: Handles custom routing logic, circuit breakers, and advanced transformations
- Features:
- Dynamic routing based on path, headers, query parameters
- Service discovery integration (Eureka)
- Load balancing across service instances
- Request/response transformation
- Circuit breakers and retries
- JWT pre-validation
- Rate limiting (global and per-user/per-API)
- IP whitelisting/blacklisting
- Comprehensive logging and metrics
- Centralized authentication and authorization
- JWT token issuance and management
- Refresh token support
- Token revocation (Redis-based blacklist)
- Role-Based Access Control (RBAC)
- OAuth2/OpenID Connect support
- Audit logging
- Eureka Server: Service discovery
- Redis: Distributed caching, rate limiting, token blacklist
- Prometheus + Grafana: Metrics and monitoring
- ELK Stack / Loki: Centralized logging
- Zipkin/Jaeger: Distributed tracing
- Docker and Docker Compose
- JDK 17 or higher
- Maven 3.8+
- Kubernetes cluster (for K8s deployment)
- Start all services:
docker compose up -d- Wait for services to be healthy:
# Check service status
docker compose ps
# View logs
docker compose logs -f auth-service- Access services:
- Kong Admin API: http://localhost:8001
- Kong Gateway: http://localhost:8000
- Auth Service: http://localhost:8080
- Eureka Dashboard: http://localhost:8761
- Grafana: http://localhost:3000 (admin/admin)
- Prometheus: http://localhost:9090
- Apply configurations:
kubectl apply -f k8s/- Check deployment status:
kubectl get pods -n hellgate
kubectl get services -n hellgatePOST /api/auth/login- User loginPOST /api/auth/register- User registrationPOST /api/auth/refresh- Refresh access tokenGET /api/auth/.well-known/jwks.json- JWKS endpoint for token verification
GET /api/auth/me- Get current user infoPOST /api/auth/logout- Logout and revoke tokenGET /api/auth/users- List users (Admin only)GET /api/auth/users/{id}- Get user detailsPUT /api/auth/users/{id}/roles- Update user roles (Admin only)
All microservice requests should go through:
http://localhost:8000/api/{service-name}/{path}
Example:
http://localhost:8000/api/user-service/usersβ routes to user-servicehttp://localhost:8000/api/order-service/ordersβ routes to order-service
See individual service READMEs:
auth-service/README.mdspring-cloud-gateway/README.mdkong/README.md
kong/kong.yml- Kong Gateway configurationauth-service/src/main/resources/application.yml- Auth service configdocker-compose.yml- Local development setupk8s/- Kubernetes manifests
- JWT Validation: All requests validated at gateway level
- Rate Limiting: Configurable per-user and per-API limits
- IP Filtering: Whitelist/blacklist support
- Token Revocation: Redis-based token blacklist
- RBAC: Role-based access control
- HTTPS: TLS/SSL support (configure in production)
- CORS: Configurable CORS policies
- Gateway metrics:
http://localhost:9090(Prometheus) - Custom dashboards:
http://localhost:3000(Grafana)
- Centralized logs: Check ELK stack or Loki
- Service logs:
docker-compose logs -f {service-name}
- Distributed traces:
http://localhost:9411(Zipkin)
# Auth Service tests
cd auth-service
mvn test
# Integration tests
mvn verify -P integration-tests# Register a user
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"password123","email":"test@example.com"}'
# Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"password123"}'
# Access protected endpoint (use token from login response)
curl -X GET http://localhost:8000/api/auth-service/api/auth/me \
-H "Authorization: Bearer {token}"- API Gateway: Kong Gateway, Spring Cloud Gateway
- Auth Service: Spring Boot 3.x, Spring Security, OAuth2
- Service Discovery: Eureka (Spring Cloud Netflix)
- Caching: Redis
- Containerization: Docker
- Orchestration: Kubernetes
- Monitoring: Prometheus, Grafana
- Logging: ELK Stack / Grafana Loki
- Tracing: Zipkin / Jaeger
spring-gateway/
βββ auth-service/ # Authentication Service (Spring Boot)
βββ spring-cloud-gateway/ # Spring Cloud Gateway (Custom Logic)
βββ kong/ # Kong Gateway Configuration
βββ example-services/ # Example Microservices
β βββ user-service/
β βββ order-service/
βββ k8s/ # Kubernetes Manifests
βββ monitoring/ # Prometheus, Grafana configs
βββ logging/ # ELK/Loki configurations
βββ docker-compose.yml # Local development setup
βββ README.md # This file
- Create service in
example-services/ - Register with Eureka
- Configure route in Kong (
kong/kong.yml) - Add route in Spring Cloud Gateway if needed
- Update service discovery config
The authentication service is designed to be extensible:
- Add custom authentication providers
- Integrate with external IDPs (Okta, Azure AD, Keycloak)
- Extend RBAC with custom permissions
-
Security:
- Enable HTTPS/TLS
- Use secrets management (K8s secrets, Vault)
- Configure proper CORS policies
- Set up firewall rules
-
Scalability:
- Horizontal scaling via Kubernetes
- Database connection pooling
- Redis cluster for high availability
-
Monitoring:
- Set up alerting rules
- Configure log retention policies
- Set up distributed tracing
MIT License
See CONTRIBUTING.md for guidelines.
For issues and questions, please open an issue in the repository.