sgivu-gateway) is the entry point for all client requests, handling OAuth2 authentication, session management, and routing to backend services.
Service Overview
Port
8080
Session Store
Redis
Protocol
OAuth2 / WebFlux
Role
API Gateway
Key Features
- Reactive API Gateway built with Spring Cloud Gateway
- OAuth2 client with authorization code flow
- Redis-based distributed session management
- Token relay to downstream services
- Session revocation and logout handling
- Service discovery integration
Base Configuration
Server Settings
The gateway uses reactive WebFlux for non-blocking request handling.
Session Management
The gateway uses Redis for distributed session storage:Redis Session Benefits
Redis Session Benefits
- Horizontal scaling: Multiple gateway instances can share sessions
- Fast access: In-memory performance for session lookups
- Automatic expiration: Redis TTL handles session cleanup
- Persistence: Sessions survive gateway restarts
OAuth2 Client Configuration
Client Registration
The
offline_access scope enables refresh token issuance for seamless token renewal.Provider Configuration
Reactive Configuration
Enables automatic context propagation for reactive security and tracing.
Service Integration
Eureka Registration
Service Discovery Map
Environment-Specific Configuration
- Development
- Production
- Detailed logging for OAuth2 flow debugging
- Token relay tracing
- Session lifecycle visibility
- Security filter chain logging
Observability
Actuator Endpoints
Distributed Tracing
Logging Configuration
Debugging Authentication Issues
Debugging Authentication Issues
To troubleshoot OAuth2 or session issues in development, enable these loggers:
API Documentation
Required Environment Variables
All Environments
| Variable | Description | Example |
|---|---|---|
REDIS_HOST | Redis server host | sgivu-redis |
REDIS_PORT | Redis server port | 6379 |
REDIS_PASSWORD | Redis password | your-redis-password |
SGIVU_GATEWAY_SECRET | OAuth2 client secret | gateway-secret |
Development
| Variable | Description |
|---|---|
DEV_ANGULAR_APP_URL | Angular frontend URL |
Production
| Variable | Description |
|---|---|
PROD_ANGULAR_APP_URL | Angular frontend URL |
OPENAPI_SERVER_URL | Public API documentation URL |
Optional
| Variable | Description | Default |
|---|---|---|
PORT | Gateway port | 8080 |
EUREKA_URL | Eureka server URL | http://sgivu-discovery:8761/eureka |
SGIVU_AUTH_URL | Auth service URL | http://sgivu-auth:9000 |
Token Relay
The gateway automatically relays OAuth2 access tokens to downstream services. This enables:- Single sign-on (SSO) across services
- Consistent user identity
- Centralized token refresh
- Automatic token propagation
Session Timeout
Sessions expire after 1 hour of inactivity. Active sessions are automatically extended.
CORS Configuration
The gateway handles CORS for all backend services:- Development
- Production
Typically allows all origins for local development:
Route Configuration
The gateway routes requests to backend services based on path patterns:/api/auth/**→ Auth Service/api/users/**→ User Service/api/clients/**→ Client Service/api/vehicles/**→ Vehicle Service/api/purchase-sales/**→ Purchase-Sale Service
Route configuration is typically defined in the gateway application code, not in external configuration.
Security Features
Session Revocation
The gateway supports logout and token revocation:- Local session deletion from Redis
- Token revocation at the authorization server
- Redirect to login page
CSRF Protection
CSRF protection is enabled for all state-changing operations.Token Refresh
Automatic token refresh using refresh tokens prevents session interruption.Configuration Files
sgivu-gateway.yml- Base configurationsgivu-gateway-dev.yml- Development overridessgivu-gateway-prod.yml- Production overrides
Related Services
Auth Service
OAuth2 authorization server
Discovery Service
Service registry