Skip to content

Commit 3a98e77

Browse files
authored
Support to persist the configaccesslist as a secret also (#9)
* Support to persist the configaccesslist as a secret also * Introducing generic annotations for cm and secret * Updating the chart version * Updated README docs to show the two options, configmap and secret
1 parent 3a6f114 commit 3a98e77

File tree

6 files changed

+51
-4
lines changed

6 files changed

+51
-4
lines changed

helm/oauth2-proxy/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: oauth2-proxy
2-
version: 3.2.6
2+
version: 3.2.7
33
apiVersion: v1
44
appVersion: 5.1.0
55
home: https://oauth2-proxy.github.io/oauth2-proxy/

helm/oauth2-proxy/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ Parameter | Description | Default
6060
--- | --- | ---
6161
`affinity` | node/pod affinities | None
6262
`authenticatedEmailsFile.enabled` | Enables authorize individual email addresses | `false`
63-
`authenticatedEmailsFile.template` | Name of the configmap that is handled outside of that chart | `""`
63+
`authenticatedEmailsFile.persistence` | Defines how the email addresses file will be projected, via a configmap or secret | `configmap`
64+
`authenticatedEmailsFile.template` | Name of the configmap or secret that is handled outside of that chart | `""`
6465
`authenticatedEmailsFile.restricted_access` | [email addresses](https://github.com/pusher/oauth2_proxy#email-authentication) list config | `""`
66+
`authenticatedEmailsFile.annotations` | configmap or secret annotations | `nil`
6567
`config.clientID` | oauth client ID | `""`
6668
`config.clientSecret` | oauth client secret | `""`
6769
`config.cookieSecret` | server specific cookie for the secret; create a new one with `openssl rand -base64 32 | head -c 32 | base64` | `""`

helm/oauth2-proxy/templates/configmap-authenticated-emails-file.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- if .Values.authenticatedEmailsFile.enabled }}
2-
{{- if .Values.authenticatedEmailsFile.restricted_access }}
2+
{{- if and (.Values.authenticatedEmailsFile.restricted_access) (eq .Values.authenticatedEmailsFile.persistence "configmap") }}
33
apiVersion: v1
44
kind: ConfigMap
55
metadata:
@@ -8,6 +8,10 @@ metadata:
88
chart: {{ template "oauth2-proxy.chart" . }}
99
heritage: {{ .Release.Service }}
1010
release: {{ .Release.Name }}
11+
{{- if .Values.authenticatedEmailsFile.annotations }}
12+
annotations:
13+
{{ toYaml .Values.authenticatedEmailsFile.annotations | indent 4 }}
14+
{{- end }}
1115
name: {{ template "oauth2-proxy.fullname" . }}-accesslist
1216
data:
1317
restricted_user_access: {{ .Values.authenticatedEmailsFile.restricted_access | quote }}

helm/oauth2-proxy/templates/deployment.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,23 @@ spec:
164164
secretName: {{ if .Values.htpasswdFile.existingSecret }}{{ .Values.htpasswdFile.existingSecret }}{{ else }} {{ template "oauth2-proxy.fullname" . }}-htpasswd-file {{ end }}
165165
{{- end }}
166166

167+
{{- if and (.Values.authenticatedEmailsFile.enabled) (eq .Values.authenticatedEmailsFile.persistence "secret") }}
168+
- name: configaccesslist
169+
secret:
170+
items:
171+
- key: restricted_user_access
172+
{{- if .Values.authenticatedEmailsFile.template }}
173+
path: {{ .Values.authenticatedEmailsFile.template }}
174+
{{- else }}
175+
path: authenticated-emails-list
176+
{{- end }}
177+
{{- if .Values.authenticatedEmailsFile.template }}
178+
secretName: {{ .Values.authenticatedEmailsFile.template }}
179+
{{- else }}
180+
secretName: {{ template "oauth2-proxy.fullname" . }}-accesslist
181+
{{- end }}
182+
{{- end }}
183+
167184
{{- if or .Values.config.existingConfig .Values.config.configFile }}
168185
- configMap:
169186
defaultMode: 420
@@ -173,7 +190,7 @@ spec:
173190
{{- if ne (len .Values.extraVolumes) 0 }}
174191
{{ toYaml .Values.extraVolumes | indent 6 }}
175192
{{- end }}
176-
{{- if .Values.authenticatedEmailsFile.enabled }}
193+
{{- if and (.Values.authenticatedEmailsFile.enabled) (eq .Values.authenticatedEmailsFile.persistence "configmap") }}
177194
- configMap:
178195
{{- if .Values.authenticatedEmailsFile.template }}
179196
name: {{ .Values.authenticatedEmailsFile.template }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if .Values.authenticatedEmailsFile.enabled }}
2+
{{- if and (.Values.authenticatedEmailsFile.restricted_access) (eq .Values.authenticatedEmailsFile.persistence "secret") }}
3+
apiVersion: v1
4+
kind: Secret
5+
type: Opaque
6+
metadata:
7+
labels:
8+
app: {{ template "oauth2-proxy.name" . }}
9+
chart: {{ template "oauth2-proxy.chart" . }}
10+
heritage: {{ .Release.Service }}
11+
release: {{ .Release.Name }}
12+
{{- if .Values.authenticatedEmailsFile.annotations }}
13+
annotations:
14+
{{ toYaml .Values.authenticatedEmailsFile.annotations | indent 4 }}
15+
{{- end }}
16+
name: {{ template "oauth2-proxy.fullname" . }}-accesslist
17+
data:
18+
restricted_user_access: {{ .Values.authenticatedEmailsFile.restricted_access | b64enc }}
19+
{{- end }}
20+
{{- end }}

helm/oauth2-proxy/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ extraEnv: []
4646
# That is part of extraArgs but since this needs special treatment we need to do a separate section
4747
authenticatedEmailsFile:
4848
enabled: false
49+
# Defines how the email addresses file will be projected, via a configmap or secret
50+
persistence: configmap
4951
# template is the name of the configmap what contains the email user list but has been configured without this chart.
5052
# It's a simpler way to maintain only one configmap (user list) instead changing it for each oauth2-proxy service.
5153
# Be aware the value name in the extern config map in data needs to be named to "restricted_user_access".
@@ -58,6 +60,8 @@ authenticatedEmailsFile:
5860
# If you override the config with restricted_access it will configure a user list within this chart what takes care of the
5961
# config map resource.
6062
restricted_access: ""
63+
annotations: {}
64+
# helm.sh/resource-policy: keep
6165

6266
service:
6367
type: ClusterIP

0 commit comments

Comments
 (0)