Add Kubernetes liveness/readiness probes and middleware order validation
- Split /health into /health/live (liveness) and /health/ready (readiness) following Kubernetes conventions. Combined /health retained for backward compatibility with existing Docker HEALTHCHECK definitions. - Add ReadyCheck and ReadyResponse models for structured readiness output. - Add _assert_middleware_order() startup check enforcing: RateLimit → Csrf → CorrelationId middleware chain. - Register CorrelationIdMiddleware, CsrfMiddleware, RateLimitMiddleware in create_app() with documented required order (reverse of processing). - Add correlation.py, csrf.py, rate_limit.py middleware modules. - Add health probe tests in test_health_probes.py. - Update test_main.py with middleware order assertion tests. - Update frontend useFetchData hook tests. - Docs: update Deployment.md with Kubernetes probe config examples.
This commit is contained in:
@@ -11,6 +11,18 @@ Correlation IDs flow through the request lifecycle:
|
||||
3. Middleware stores in structlog.contextvars
|
||||
4. All log entries include the correlation ID automatically
|
||||
5. Error responses include the correlation ID for client-side correlation
|
||||
|
||||
Processing order
|
||||
-----------------
|
||||
This middleware must be the outermost in the security-critical chain so it
|
||||
executes first on incoming requests (outermost = first to see request,
|
||||
last to see response). In the required chain:
|
||||
|
||||
CorrelationIdMiddleware → CsrfMiddleware → RateLimitMiddleware
|
||||
|
||||
The registration order in ``main.py`` must be:
|
||||
RateLimitMiddleware, CsrfMiddleware, CorrelationIdMiddleware
|
||||
(last registered = outermost in Starlette's reverse application).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
Reference in New Issue
Block a user