Adds the gateway-request-logging main spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2.7 KiB
Purpose
The gateway keeps a log line for each request it routes, so operators can trace traffic, without ever writing request bodies, personal data or credentials to that log.
ADDED Requirements
Requirement: Request log carries no request body
The gateway SHALL log each routed request, except skip-listed and /actuator paths, as one line with the method, the path and the request headers. It MUST NOT write any part of the request body to the log, for any method or content type. The downstream service MUST receive the original request body unchanged.
Scenario: Lead update body stays out of the log
- GIVEN a PUT or POST with a JSON body holding a lead's name, mobile, email and notes
- WHEN the gateway routes it
- THEN the log line holds the method and the path
- AND none of the name, mobile, email or notes appears in the log
- AND the downstream service receives the body byte for byte
Scenario: Login body stays out of the log
- GIVEN a customer login POST with a username and a password in a JSON body
- WHEN the gateway routes it
- THEN neither the username nor the password appears in the log
Scenario: Form body stays out of the log
- GIVEN a form-encoded POST with a username and a password
- WHEN the gateway routes it
- THEN no field name or value from the body appears in the log
Scenario: Empty body is still routed
- GIVEN a POST with no body
- WHEN the gateway routes it
- THEN the request is logged and reaches the downstream service with no body
Scenario: Skip-listed path is not logged
- WHEN a request to
/auth/authenticatepasses through the gateway - THEN nothing about it is written to the request log
Requirement: Credentials in headers and paths are masked
The gateway SHALL mask the values of credential headers (Authorization, Proxy-Authorization, api-key, x-api-key, Cookie, Set-Cookie, X-XSRF-TOKEN, X-CSRF-TOKEN) and any JWT-shaped path segment in the request log. Header names and other header values MUST stay readable. The query string MUST NOT be logged.
Scenario: Authorization and api-key are masked
- GIVEN a request with an Authorization bearer token, an api-key and an Accept header
- WHEN the gateway logs it
- THEN the token and the key do not appear in the log
- AND the Accept header value does
Scenario: JWT in the path is masked
- WHEN a request to
/auth/findUserByToken/M/<jwt>is logged - THEN the log shows
/auth/findUserByToken/M/***
Scenario: Search term in the query string is not logged
- WHEN a GET with the query string
?q=aisyahis logged - THEN the log shows the path without
aisyah