This document helps automation agents work effectively on the Wachter service.
- Purpose: authorize requests from Control Center and transparently proxy them to domain services.
- Stack: Java 21, Spring Boot 3, RestClient (JDK HTTP), OpenTelemetry (OTLP/HTTP), Woody tracing library, JWT via Spring Security.
- Tracing Flow:
WoodyTracingFilternormalizes Woody headers, hydrates Woody trace context, starts an OpenTelemetry span, and stores normalized headers in the request. - Proxy Flow:
WachterServiceperforms access checks,WachterClient(usingRestClient) forwards requests, andWachterControllerreturns upstream status/headers/body unchanged.
dev.vality.wachter.config– Spring configuration;ApplicationConfig,WebConfig,OtelConfig.dev.vality.wachter.config.tracing– tracing helpers (WoodyHeadersNormalizer,WoodyTraceContextApplier,WoodyTelemetrySupport,WoodyTracingFilter).dev.vality.wachter.client– outbound proxy pieces (WachterClient,WachterRequestFactory,WachterClientResponse).dev.vality.wachter.security– access control (AccessService,RoleAccessService,JwtTokenDetailsExtractor).dev.vality.wachter.service– application services (WachterService,MethodNameReaderService).dev.vality.wachter.controller– REST controllers (WachterController, error handling tests).dev.vality.wachter.constants– header/attribute constants.
- Unit tests:
mvn test(runs JUnit + WireMock integration suite). - Key suites:
WachterClient*Test,WebConfigTest, controller tests,WachterIntegrationTest(WireMock-based end-to-end proxy verification). - Ensure new features include coverage across: header normalization, trace context propagation, authorization checks, proxy behaviour.
- Maintain dual Woody headers (
woody.*+x-woody-*). - Preserve upstream responses exactly (status, headers, body).
- Use
JwtTokenDetailsExtractorfor JWT-derived values; avoid duplicating claim parsing. - When touching tracing, ensure OpenTelemetry span attributes (
HTTP_*,traceparent) remain intact. - Follow existing Checkstyle conventions:
finalfor immutable locals, concise logging via SLF4J, minimal inline comments. - Update documentation only when requested.
- Modify tracing behaviour: inspect
config/tracingclasses; update tests inWebConfigTestandWachterIntegrationTest. - Adjust outbound proxying: change
WachterRequestFactory/WachterClient; add/update tests inclientpackage and integration suite. - Authorization changes: update
AccessService,RoleAccessService; extend security tests accordingly.
- Run full suite:
mvn test - Format/imports: rely on IDE (no automatic formatter configured).
- Generate coverage (optional):
mvn test -Pcoverage(if profile exists; verify before use).
WachterControllerenforces deadline checks before proxying; always keepDeadlineUtilbehaviour in mind.WoodyHeadersNormalizermerges JWT metadata and deadlines with priority rules—changing behaviour requires revisiting corresponding tests.- Integration tests spin up WireMock; avoid port conflicts by keeping default configuration.
Stay aligned with the README and trace plans when planning new work.