iac/infrastructure/security-audit/mesh/strip-audit-headers.yaml

33 lines
1.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Удаляет входящие x-sarex-audit-*: клиент не должен подставлять себе пользователя в журнал доступа.
# Стоит первым HTTP-фильтром (INSERT_FIRST) — раньше jwt_authn, который заполняет эти заголовки из claims.
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: strip-audit-headers
namespace: istio-system
spec:
workloadSelector:
labels:
security-audit/gateway: unset
configPatches:
- applyTo: HTTP_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
patch:
operation: INSERT_FIRST
value:
name: security-audit.strip-audit-headers
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
default_source_code:
inline_string: |
function envoy_on_request(request_handle)
local headers = request_handle:headers()
headers:remove("x-sarex-audit-sub")
headers:remove("x-sarex-audit-org")
end