From 6fa122207e933e284d107fd98f94b877c6deafb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tailland?= Date: Fri, 21 Aug 2026 14:40:20 +0200 Subject: [PATCH] Capture request/response bodies in audit-log, extend it to MCP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit custom_fields_by_lua adds request_body/response_body to the http-log payload. Bodies and the raw Authorization header are now both logged in clear text — dev only, flagged in the plugin file itself. --- kong/kustomization.yaml | 1 + kong/mcp/audit-log.yaml | 15 +++++++++++++++ kong/mcp/pluginbindings.yaml | 18 ++++++++++++++++++ kong/rest/audit-log.yaml | 5 +++++ 4 files changed, 39 insertions(+) create mode 100644 kong/mcp/audit-log.yaml diff --git a/kong/kustomization.yaml b/kong/kustomization.yaml index da79e6f..b84d667 100644 --- a/kong/kustomization.yaml +++ b/kong/kustomization.yaml @@ -15,4 +15,5 @@ resources: - mcp/consumergroups.yaml - mcp/ai-mcp-proxy.yaml - mcp/openid-connect.yaml + - mcp/audit-log.yaml - mcp/pluginbindings.yaml diff --git a/kong/mcp/audit-log.yaml b/kong/mcp/audit-log.yaml new file mode 100644 index 0000000..311176e --- /dev/null +++ b/kong/mcp/audit-log.yaml @@ -0,0 +1,15 @@ +apiVersion: configuration.konghq.com/v1 +kind: KongPlugin +metadata: + name: ${NAME}-catalog-mcp-audit-log + namespace: ${NAMESPACE} +plugin: http-log +# dev only: request/response bodies and the raw Authorization (JWT) header +# are captured in clear text. Not acceptable as-is for a non-dev environment. +config: + http_endpoint: ${AUDIT_LOG_ENDPOINT} + method: POST + content_type: application/json + custom_fields_by_lua: + request_body: "return kong.request.get_raw_body()" + response_body: "return kong.response.get_raw_body()" diff --git a/kong/mcp/pluginbindings.yaml b/kong/mcp/pluginbindings.yaml index 71dcf06..18fbbc3 100644 --- a/kong/mcp/pluginbindings.yaml +++ b/kong/mcp/pluginbindings.yaml @@ -33,3 +33,21 @@ spec: group: configuration.konghq.com kind: KongRoute name: ${NAME}-catalog-mcp +--- +apiVersion: configuration.konghq.com/v1alpha1 +kind: KongPluginBinding +metadata: + name: ${NAME}-catalog-mcp-audit-log-binding + namespace: ${NAMESPACE} +spec: + controlPlaneRef: + type: konnectNamespacedRef + konnectNamespacedRef: + name: ${CONTROL_PLANE_REF_NAME} + pluginRef: + name: ${NAME}-catalog-mcp-audit-log + targets: + serviceRef: + group: configuration.konghq.com + kind: KongService + name: ${NAME}-catalog-mcp diff --git a/kong/rest/audit-log.yaml b/kong/rest/audit-log.yaml index c5d3d08..7723d30 100644 --- a/kong/rest/audit-log.yaml +++ b/kong/rest/audit-log.yaml @@ -4,7 +4,12 @@ metadata: name: ${NAME}-catalog-api-audit-log namespace: ${NAMESPACE} plugin: http-log +# dev only: request/response bodies and the raw Authorization (JWT) header +# are captured in clear text. Not acceptable as-is for a non-dev environment. config: http_endpoint: ${AUDIT_LOG_ENDPOINT} method: POST content_type: application/json + custom_fields_by_lua: + request_body: "return kong.request.get_raw_body()" + response_body: "return kong.response.get_raw_body()"