Skip to content

Commit

Permalink
Add basic authentication support to the Ingress configuration and cr…
Browse files Browse the repository at this point in the history
…eate a secret for the basic authentication credentials in Kuberoapp.
  • Loading branch information
mms-gianni committed Jan 10, 2025
1 parent f5a2738 commit ffc5830
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helm-charts/kuberoapp/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ metadata:
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- if gt (len .Values.basicAuth.accounts) 0 }}
nginx.ingress.kubernetes.io/auth-secret: {{ include "kuberoapp.fullname" . }}-htpasswd
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-realm: {{ .Values.basicAuth.realm | quote }}
{{- end }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
Expand Down
15 changes: 15 additions & 0 deletions helm-charts/kuberoapp/templates/secret-basic-auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if gt (len .Values.basicAuth.accounts) 0 }}
{{- $accounts := .Values.basicAuth.accounts }}
{{- $val := "" }}
{{- range $account := $accounts }}
{{- $hash := htpasswd $account.user $account.password }}
{{- $val = printf "%s%s\n" $val $hash }}
{{- end }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "kuberoapp.fullname" . }}-htpasswd
type: Opaque
data:
auth: {{ $val | trimSuffix "\n" | b64enc }}
{{- end }}
8 changes: 8 additions & 0 deletions helm-charts/kuberoapp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ resources: {}
# cpu: 100m
# memory: 128Mi

basicAuth:
realm: "Protected"
accounts: []
#- user: foo
# password: bar
#- user: bar
# password: foo

autoscaling:
enabled: false

Expand Down

0 comments on commit ffc5830

Please sign in to comment.