Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow for overwritting the cookie-domain flag on the oidc proxy #157

Merged
merged 21 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion stack/templates/oidc_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,29 @@ spec:
{{- end -}}

{{- range .Values.oidcProxy.skipAuth }}
# for backwards compatibility, could also just be provided using extraArgs
{{ if contains "*" .method }}
# for backwards compatibility, could also just be provided using extraArgs
- --skip-auth-route={{ .path }}
{{- else -}}
- --skip-auth-route={{ .method }}={{ .path }}
{{- end -}}
{{- end -}}

{{ $cookiePrefix := list }}
{{ range .Values.oidcProxy.extraArgs }}
{{ if (hasPrefix "--cookie-domain" . ) }}
{{ $cookiePrefix = append $cookiePrefix . }}
{{ end }}
{{ end }}
{{- range $allHosts -}}
{{- printf "- --whitelist-domain=%s" . | nindent 12 -}}

{{ if eq (len $cookiePrefix) 0 }}
# if a user provides a cookie-domain flag, we want to use that instead of the
# default cookie-domain
{{- printf "- --cookie-domain=%s" . | nindent 12 -}}
{{ end }}

{{- end -}}
{{- if gt (len .Values.oidcProxy.extraArgs) 0 }}
{{- toYaml .Values.oidcProxy.extraArgs | nindent 12}}
Expand Down
51 changes: 51 additions & 0 deletions stack/tests/oidc_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,54 @@ tests:
contains:
path: spec.template.spec.containers[0].args
content: --cookie-domain=stack2.com
- it: should allow for overwriting the cookie-domain flag
set:
global:
ingress:
host: "stack.play.dev.czi.team"
oidcProxy:
enabled: true
extraArgs:
- "--cookie-domain=someparent.domain"
services:
service1:
ingress:
oidcProtected: true
paths:
- path: "/service1"
pathType: Prefix
rules:
- host: "app1.someparent.domain"
service2:
ingress:
oidcProtected: true
paths:
- path: "/service2"
pathType: Prefix
rules:
- host: "app2.someparent.domain"
asserts:
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].args
content: --whitelist-domain=app1.someparent.domain
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].args
content: --whitelist-domain=app2.someparent.domain
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].args
content: --whitelist-domain=.czi.team
- documentIndex: 0
notContains:
path: spec.template.spec.containers[0].args
content: --cookie-domain=app1.someparent.domain
- documentIndex: 0
notContains:
path: spec.template.spec.containers[0].args
content: --cookie-domain=app2.someparent.domain
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].args
content: --cookie-domain=someparent.domain
Loading