Skip to content

Commit

Permalink
feat: add oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
walkoss committed Apr 15, 2023
1 parent 0cd778c commit ca46433
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 7 deletions.
7 changes: 5 additions & 2 deletions unleash/helm/unleash/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ dependencies:
- name: unleash
repository: https://docs.getunleash.io/helm-charts
version: 2.8.0
digest: sha256:552bc226be5e707e130af94d16402b37a8588fe3be7c7eca90dd275ffa3a2cd3
generated: "2023-04-15T05:20:25.085317+02:00"
- name: oidc-config
repository: https://pluralsh.github.io/module-library
version: 0.1.6
digest: sha256:e72b181785ed4af17a09f15eb96d8ed5eb97de0017d026e0847f2fc521317e01
generated: "2023-04-15T13:09:41.222634+02:00"
6 changes: 5 additions & 1 deletion unleash/helm/unleash/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ dependencies:
repository: https://pluralsh.github.io/module-library
- name: unleash
version: 2.8.0
repository: https://docs.getunleash.io/helm-charts
repository: https://docs.getunleash.io/helm-charts
- name: oidc-config
version: 0.1.6
repository: https://pluralsh.github.io/module-library
condition: oidc-config.enabled
Binary file added unleash/helm/unleash/charts/oidc-config-0.1.6.tgz
Binary file not shown.
61 changes: 61 additions & 0 deletions unleash/helm/unleash/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := index .Values "oidc-config" "service" "name" -}}
{{- $svcPort := index .Values "oidc-config" "service" "webPort" -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "unleash-plural.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions unleash/helm/unleash/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ unleash:
key: password
ssl: '{\"rejectUnauthorized\": false}'

oidc-config:
enabled: false
service:
name: unleash-oauth2-proxy
selector:
app.kubernetes.io/instance: unleash
app.kubernetes.io/name: unleash
secret:
upstream: http://localhost:4242
env:
OAUTH2_PROXY_UPSTREAM_TIMEOUT: '120s'

ingress:
enabled: false
48 changes: 46 additions & 2 deletions unleash/helm/unleash/values.yaml.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
unleash:
{{- if .OIDC }}
ingress:
enabled: false
{{ else }}
ingress:
enabled: true
className: "nginx"
Expand All @@ -14,10 +18,11 @@ unleash:
- secretName: unleash-tls
hosts:
- {{ .Values.hostname }}
{{ end }}
env:
- name: UNLEASH_URL
value: {{ .Values.hostname }}
{{ if .SMTP }}
{{ if .SMTP }}
- name: EMAIL_SERVER_HOST
value: {{ .SMTP.Server }}
- name: EMAIL_SERVER_USER
Expand All @@ -28,4 +33,43 @@ unleash:
value: {{ .SMTP.Port }}
- name: EMAIL_FROM
value: {{ .SMTP.Sender }}
{{ end }}
{{ end }}
{{ if .OIDC }}
- name: AUTH_TYPE
value: none
podLabels:
security.plural.sh/inject-oauth-sidecar: "true"
podAnnotations:
security.plural.sh/oauth-env-secret: "unleash-proxy-config"
{{ if .Values.users }}
security.plural.sh/htpasswd-secret: httpaswd-users
{{ end }}
{{ $prevSecret := dedupe . "unleash.oidc-config.cookieSecret" (randAlphaNum 32) }}
oidc-config:
enabled: true
secret:
name: unleash-proxy-config
issuer: {{ .OIDC.Configuration.Issuer }}
clientID: {{ .OIDC.ClientId }}
clientSecret: {{ .OIDC.ClientSecret }}
cookieSecret: {{ dedupe . "unleash.oidc-config.secret.cookieSecret" $prevSecret }}
{{ if .Values.users }}
users:
{{ toYaml .Values.users | nindent 4 }}
{{ end }}
ingress:
enabled: true
className: "nginx"
annotations:
kubernetes.io/tls-acme: "true"
cert-manager.io/cluster-issuer: letsencrypt-prod
hosts:
- host: {{ .Values.hostname }}
paths:
- path: '/'
pathType: ImplementationSpecific
tls:
- secretName: unleash-tls
hosts:
- {{ .Values.hostname }}
{{ end }}
9 changes: 7 additions & 2 deletions unleash/plural/notes.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Your unleash installation is available at https://{{ .Values.hostname }}
The default login is admin/unleash4all.
We strongly recommend you change it at https://{{ .Values.hostname }}/profile/change-password
{{ if .OIDC }}
Your directus has been configured with OAuth against your plural account!
{{ else }}
You are using standard username/password authentication, so user management will be manual.
The default login is admin/unleash4all. We recommend to change it at https://{{ .Values.hostname }}/profile/change-password
We strongly recommend that you consider installing with OIDC enabled.
{{ end }}

0 comments on commit ca46433

Please sign in to comment.