From 1e7a2d484b317929b6c6bbee57b43b971dcb4fd5 Mon Sep 17 00:00:00 2001 From: Marco Rodolfi Date: Fri, 24 Nov 2023 17:54:10 +0100 Subject: [PATCH 1/3] Added rewriteResponseBody as a middleware --- .../middlewares/rewriteResponseBody.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml diff --git a/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml new file mode 100644 index 000000000000..8a6df849e96c --- /dev/null +++ b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml @@ -0,0 +1,17 @@ +{{- range $index, $middlewareData := .Values.middlewares.rewriteResponseBody }} +--- +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: {{ ternary (printf "%v-%v" $.Release.Name $middlewareData.name) $middlewareData.name $.Values.ingressClass.enabled }} + namespace: {{ $.Release.Namespace }} +spec: + plugin: + plugin-rewritebody: + lastModified: "true" + rewrites: + {{- range $index, $rewriteResponseHeader := $middlewareData.headers }} + - regex: {{ $rewriteResponseHeader.regex | quote }} + replacement: {{ $rewriteResponseHeader.replacement | quote }} + {{- end }} +{{- end -}} From dbf9c7ad78846aa82524b70248ea7cc4ce218c5f Mon Sep 17 00:00:00 2001 From: Marco Rodolfi Date: Fri, 24 Nov 2023 19:14:58 +0100 Subject: [PATCH 2/3] Attempt at adding missing parameters --- .../middlewares/rewriteResponseBody.yaml | 6 +-- charts/enterprise/traefik/values.yaml | 5 +++ .../rewriteResponseBodyMiddleware.yaml | 41 +++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 templates/questions/traefik/rewriteResponseBodyMiddleware.yaml diff --git a/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml index 8a6df849e96c..7c95c4e2b16d 100644 --- a/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml +++ b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml @@ -10,8 +10,8 @@ spec: plugin-rewritebody: lastModified: "true" rewrites: - {{- range $index, $rewriteResponseHeader := $middlewareData.headers }} - - regex: {{ $rewriteResponseHeader.regex | quote }} - replacement: {{ $rewriteResponseHeader.replacement | quote }} + {{- range $index, $rewriteResponseBody := $middlewareData.headers }} + - regex: {{ $rewriteResponseBody.regex | quote }} + replacement: {{ $rewriteResponseBody.replacement | quote }} {{- end }} {{- end -}} diff --git a/charts/enterprise/traefik/values.yaml b/charts/enterprise/traefik/values.yaml index b3f73ad87e12..ea911f119c04 100644 --- a/charts/enterprise/traefik/values.yaml +++ b/charts/enterprise/traefik/values.yaml @@ -338,6 +338,11 @@ middlewares: # - name: "Date" # regex: "^[^,]+,\\s*(.+)$" # replacement: "$1" + rewriteResponseBody: [] + # - name: rewriteResponseBodyName + # headers: + # - regex = "foo" + # replacement = "bar" customFrameOptionsValue: [] # - name: customFrameOptionsValueExample # value: "SAMEORIGIN" diff --git a/templates/questions/traefik/rewriteResponseBodyMiddleware.yaml b/templates/questions/traefik/rewriteResponseBodyMiddleware.yaml new file mode 100644 index 000000000000..7f98e0c4d646 --- /dev/null +++ b/templates/questions/traefik/rewriteResponseBodyMiddleware.yaml @@ -0,0 +1,41 @@ + - variable: rewriteResponseBody + label: Rewrite Response Body + schema: + type: list + default: [] + items: + - variable: rewriteResponseBodyEntry + label: "" + schema: + additional_attrs: true + type: dict + attrs: + - variable: name + label: Name + schema: + type: string + required: true + - variable: headers + label: HTML body sections to replace + schema: + type: list + default: [] + items: + - variable: bodyEntry + label: "" + schema: + additional_attrs: true + type: dict + attrs: + - variable: regex + label: Regex + description: The value of the HTML code to match. Accepts regex expression. + schema: + type: string + default: "" + - variable: replacement + label: Replacement Regex + description: The replacement HTML code to substitute. Accepts regex expression. + schema: + type: string + default: "" From 5347702af902da2ef5b416d35e1fafe87bf9e0ea Mon Sep 17 00:00:00 2001 From: Marco Rodolfi Date: Fri, 24 Nov 2023 19:22:05 +0100 Subject: [PATCH 3/3] Bump version Signed-off-by: Marco Rodolfi --- charts/enterprise/traefik/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/enterprise/traefik/Chart.yaml b/charts/enterprise/traefik/Chart.yaml index 1317f0f0c33a..0426f68c5b89 100644 --- a/charts/enterprise/traefik/Chart.yaml +++ b/charts/enterprise/traefik/Chart.yaml @@ -23,7 +23,7 @@ sources: - https://github.com/traefik/traefik-helm-chart - https://traefik.io/ type: application -version: 21.1.9 +version: 21.1.10 annotations: truecharts.org/category: network truecharts.org/SCALE-support: "true"