From ac47ece75fdb79c3d16cc447aa4fea8875944be3 Mon Sep 17 00:00:00 2001 From: Jake Heath <76011913+jakeyheath@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:44:52 -0700 Subject: [PATCH] feat: don't use nonchars in variable name (#115) --- stack/templates/_helpers.tpl | 6 +----- stack/tests/ingress_test.yaml | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/stack/templates/_helpers.tpl b/stack/templates/_helpers.tpl index dde7e7c..f0cbe2b 100644 --- a/stack/templates/_helpers.tpl +++ b/stack/templates/_helpers.tpl @@ -186,14 +186,10 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{ join "." (list (include "oidcProxy.name" .) (include "clusterBaseDomain" .)) }} {{- end -}} -{{- define "oidcProxy.skipAuth" -}} -{{- $id := printf "%s_%s" (.method |lower) (.path | replace "/" "") }} -{{ $id }} -{{- end -}} - {{- define "oidcProxy.skipAuthConfig" -}} {{- range $k, $v := .Values.global.oidcProxy.skipAuth -}} {{- $id := printf "%s_%s" ($v.method |lower) ($v.path | replace "/" "")}} +{{- $id := regexReplaceAll "\\W+" $id "_" -}} {{- $var_name := printf "%s_%s" "skip_auth" $id }} set {{ $var_name }} 1; diff --git a/stack/tests/ingress_test.yaml b/stack/tests/ingress_test.yaml index 21c422e..4af5759 100644 --- a/stack/tests/ingress_test.yaml +++ b/stack/tests/ingress_test.yaml @@ -60,6 +60,8 @@ tests: skipAuth: - path: /healthz method: GET + - path: /api/* + method: "*" services: service1: ingress: @@ -84,3 +86,16 @@ tests: if ( skip_auth_get_healthz ) { return 200; } + set skip_auth___api_ 1; + + if ( $request_uri !~ "/api/*" ) { + set skip_auth___api_ 0; + } + + if ( $request_method !~ "*" ) { + set skip_auth___api_ 0; + } + + if ( skip_auth___api_ ) { + return 200; + }