Skip to content

Commit

Permalink
fix: unique domain names for oidcProxy per stack
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeyheath committed Sep 5, 2024
1 parent d91e7ab commit 2f42b13
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
8 changes: 6 additions & 2 deletions stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,17 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- end -}}

{{ define "oidcProxy.envFrom"}}
{{- define "oidcProxy.envFrom" -}}
{{- include "oidcProxy.envFromArgusSecrets" . }}
{{- include "oidcProxy.additionalSecrets" . }}
{{- end -}}

{{- define "oidcProxy.authDomain" -}}
{{ join "." (list (include "oidcProxy.name" .) (include "clusterBaseDomain" .)) }}
{{- end -}}

{{- define "oidcProxy.nginxAuthAnnotations" -}}
nginx.ingress.kubernetes.io/auth-url: "http://{{ include "oidcProxy.name" . }}.{{ .Release.Namespace }}.svc.cluster.local:4180/oauth2/auth"
nginx.ingress.kubernetes.io/auth-signin: "https://auth.{{- include "clusterBaseDomain" . }}/oauth2/start?rd=https://$host$escaped_request_uri"
nginx.ingress.kubernetes.io/auth-signin: "https://{{- include "oidcProxy.authDomain" . }}/oauth2/start?rd=https://$host$escaped_request_uri"
nginx.ingress.kubernetes.io/auth-response-headers: Authorization
{{- end -}}
2 changes: 1 addition & 1 deletion stack/templates/oidc_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ metadata:
spec:
ingressClassName: nginx
rules:
- host: auth.{{- include "clusterBaseDomain" . }}
- host: {{ include "oidcProxy.authDomain" . }}
http:
paths:
- path: /oauth2
Expand Down
2 changes: 1 addition & 1 deletion stack/tests/ingress_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tests:
- documentIndex: 0
equal:
path: metadata.annotations["nginx.ingress.kubernetes.io/auth-signin"]
value: "https://auth.play.dev.czi.team/oauth2/start?rd=https://$host$escaped_request_uri"
value: "https://release-name-stack-oidc-proxy.play.dev.czi.team/oauth2/start?rd=https://$host$escaped_request_uri"
- documentIndex: 0
equal:
path: metadata.annotations["nginx.ingress.kubernetes.io/auth-response-headers"]
Expand Down
16 changes: 15 additions & 1 deletion stack/tests/oidc_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ tests:
asserts:
- hasDocuments:
count: 0
- it: is enabled by default
- it: make the appropriate resources when enabled
set:
global:
oidcProxy:
enabled: true
asserts:
- hasDocuments:
count: 3
Expand All @@ -30,10 +34,15 @@ tests:
kind: Ingress
apiVersion: networking.k8s.io/v1
name: release-name-stack-oidc-proxy
- it: disabled by default
asserts:
- hasDocuments:
count: 0
- it: sets additionalSecrets in envFrom
set:
global:
oidcProxy:
enabled: true
additionalSecrets:
- secretRef:
name: blah1
Expand All @@ -57,6 +66,7 @@ tests:
clusterSecret:
secretName: blah5
oidcProxy:
enabled: true
additionalSecrets:
- secretRef:
name: blah1
Expand All @@ -70,6 +80,10 @@ tests:
path: spec.template.spec.containers[0].envFrom
count: 5
- it: defaults to 0 envFrom object
set:
global:
oidcProxy:
enabled: true
asserts:
- documentIndex: 0
equal:
Expand Down
2 changes: 1 addition & 1 deletion stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ global:
existingClaim: ""
mountPath: ""
oidcProxy:
enabled: true
enabled: false
image:
repository: quay.io/oauth2-proxy/oauth2-proxy
tag: v7.6.0
Expand Down

0 comments on commit 2f42b13

Please sign in to comment.