Skip to content

Commit

Permalink
refactor: adjust secret generation to be more user friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-elliott committed Feb 15, 2021
1 parent a7fbb83 commit e901733
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/authelia/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: authelia
version: 0.1.3
version: 0.1.4
kubeVersion: ">= 1.13.0"
description: Authelia is a Single Sign-On Multi-Factor portal for web apps
type: application
Expand Down
76 changes: 76 additions & 0 deletions charts/authelia/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,82 @@ Returns true if pod is stateful.
{{- end -}}
{{- end -}}

{{/*
Returns true if redis is configured.
*/}}
{{- define "authelia.configured.redis" -}}
{{- if .Values.configMap -}}
{{- if .Values.configMap.session -}}
{{- if .Values.configMap.session.redis -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Returns true if redis secret is configured.
*/}}
{{- define "authelia.configured.redisSecret" -}}
{{- if .Values.secret -}}
{{- if .Values.secret.redis -}}
{{- if hasKey .Values.secret.redis "value" -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Returns true if smtp is enabled.
*/}}
{{- define "authelia.configured.smtp" -}}
{{- if .Values.configMap -}}
{{- if .Values.configMap.notifier -}}
{{- if .Values.configMap.notifier.smtp -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Returns true if smtp secret is configured.
*/}}
{{- define "authelia.configured.smtpSecret" -}}
{{- if .Values.secret -}}
{{- if .Values.secret.smtp -}}
{{- if hasKey .Values.secret.smtp "value" -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Returns true if duo is enabled.
*/}}
{{- define "authelia.configured.duo" -}}
{{- if .Values.configMap -}}
{{- if .Values.configMap.duo_api -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Returns true if duo secret is configured.
*/}}
{{- define "authelia.configured.duoSecret" -}}
{{- if .Values.secret -}}
{{- if .Values.secret.duo -}}
{{- if hasKey .Values.secret.duo "value" -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Returns the name of the chain Middleware for forward auth which gets applied to other IngressRoutes.
*/}}
Expand Down
6 changes: 3 additions & 3 deletions charts/authelia/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ data:
{{- .Values.secret.session.key | nindent 2 }}: {{ include "authelia.secret.standard" (merge (dict "SecretValue" .Values.secret.session.value) .) }}
{{- .Values.secret.ldap.key | nindent 2 }}: {{ include "authelia.secret.standard" (merge (dict "SecretValue" .Values.secret.ldap.value) .) }}
{{- .Values.secret.storage.key | nindent 2 }}: {{ include "authelia.secret.standard" (merge (dict "SecretValue" .Values.secret.storage.value) .) }}
{{- if .Values.secret.redis.enabled }}
{{- if or (include "authelia.configured.redis" .) (include "authelia.configured.redisSecret" .) }}
{{- .Values.secret.redis.key | nindent 2 }}: {{ include "authelia.secret.standard" (merge (dict "SecretValue" .Values.secret.redis.value) .) }}
{{- end }}
{{- if .Values.secret.smtp.enabled }}
{{- if or (include "authelia.configured.smtp" .) (include "authelia.configured.smtpSecret" .) }}
{{- .Values.secret.smtp.key | nindent 2 }}: {{ include "authelia.secret.standard" (merge (dict "SecretValue" .Values.secret.smtp.value) .) }}
{{- end }}
{{- if and .Values.configMap.duo_api .Values.secret.duo.value }}
{{- if or (include "authelia.configured.duo" .) (include "authelia.configured.duoSecret" .) }}
{{- .Values.secret.duo.key | nindent 2 }}: {{ .Values.secret.duo.value | b64enc }}
{{- end }}
{{- end -}}
2 changes: 0 additions & 2 deletions charts/authelia/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -856,11 +856,9 @@ secret:
key: DUO_API_KEY
# value:
redis:
enabled: false
key: REDIS_PASSWORD
# value:
smtp:
enabled: false
key: SMTP_PASSWORD
# value:

Expand Down

0 comments on commit e901733

Please sign in to comment.