helm-charts/authentik-application/templates/secrets.yaml

171 lines
6.8 KiB
YAML
Raw Normal View History

2023-09-03 14:58:07 +02:00
{{- $clientID := .Values.blueprint.provider.clientID }}
{{- $clientSecret := .Values.blueprint.provider.clientSecret }}
{{- $bindPolicyID := .Values.blueprint.application.bindPolicyID }}
{{- if or (and .Values.blueprint.provider.enabled (not $clientID) (not $clientSecret)) (and (not $bindPolicyID) (eq (len .Values.blueprint.groups) 0)) }}
2023-09-03 14:58:07 +02:00
---
{{- $secretName := .Values.secret.name | default (include "authentik-application.fullname" .) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $secretName }}
labels:
{{- include "authentik-application.labels" . | nindent 4 }}
{{- with .Values.secret.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
stringData:
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $secretName) | default dict }}
{{- $secretData := (get $secretObj "data") | default dict }}
{{- $bindPolicyIDCoded := (get $secretData "bindPolicyID") | default (uuidv4 | b64enc) }}
{{- $bindPolicyID = $bindPolicyID | default ($bindPolicyIDCoded | b64dec) }}
bindPolicyID: {{ $bindPolicyID | quote }}
{{- if .Values.blueprint.provider.enabled }}
2023-09-03 14:58:07 +02:00
issuerURL: {{ print .Values.blueprint.authentik.domain "/application/o/" .Values.blueprint.application.slug "/" }}
2023-09-03 14:58:07 +02:00
{{- $clientIDCoded := (get $secretData "clientID") | default (randAlphaNum 32 | b64enc) }}
{{- $clientID = $clientID | default ($clientIDCoded | b64dec) }}
2023-09-03 14:58:07 +02:00
clientID: {{ $clientID | quote }}
2023-09-03 14:58:07 +02:00
{{- $clientSecretCoded := (get $secretData "clientSecret") | default (randAlphaNum 32 | b64enc) }}
{{- $clientSecret = $clientSecret | default ($clientSecretCoded | b64dec) }}
2023-09-03 14:58:07 +02:00
clientSecret: {{ $clientSecret | quote }}
2023-09-03 14:58:07 +02:00
redirectURL: {{ .Values.blueprint.provider.redirectURL }}
2023-09-03 14:58:07 +02:00
{{- with .Values.blueprint.provider.tokenDuration }}
tokenDuration: {{ . | quote }}
{{- end }}
2023-09-03 14:58:07 +02:00
{{- with .Values.blueprint.provider.scopes }}
customScopes: {{ . | join "," | quote }}
{{- end }}
2023-09-03 14:58:07 +02:00
{{- with .Values.blueprint.provider.claimUsername }}
claimUsername: {{ . | quote }}
{{- end }}
2023-09-03 14:58:07 +02:00
{{- with .Values.blueprint.provider.claimGroups }}
claimGroups: {{ . | quote }}
{{- end }}
{{- end }}
2023-09-03 14:58:07 +02:00
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "authentik-application.fullname" . }}-blueprint
labels:
{{- include "authentik-application.labels" . | nindent 4 }}
{{- with .Values.blueprint.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
stringData:
blueprint.yaml: |-
version: 1
metadata:
name: {{ include "authentik-application.fullname" . }}
entries:
{{- if .Values.blueprint.provider.enabled }}
2023-09-03 14:58:07 +02:00
- model: authentik_providers_oauth2.OAuth2Provider
id: {{ .Values.blueprint.provider.name | default (include "authentik-application.fullname" .) }}
identifiers:
name: {{ .Values.blueprint.provider.name | default (include "authentik-application.fullname" .) }}
state: present
attrs:
authorization_flow: !Find [authentik_flows.flow, [slug, {{ .Values.blueprint.provider.authorizationFlow }}]]
client_type: {{ .Values.blueprint.provider.clientType | quote }}
client_id: {{ $clientID | quote }}
client_secret: {{ $clientSecret | quote }}
redirect_uris: {{ .Values.blueprint.provider.redirectURL }}
{{- with .Values.blueprint.provider.tokenDuration }}
access_token_validity: {{ . | quote }}
{{- end }}
{{- with .Values.blueprint.provider.signingKey }}
signing_key: !Find [authentik_crypto.CertificateKeyPair, [name, {{ . }}]]
{{- end }}
{{- with .Values.blueprint.provider.scopes }}
property_mappings:
{{- range . }}
- !Find [authentik_providers_oauth2.ScopeMapping, [scope_name, {{ . }}]]
{{- end }}
{{- end }}
{{- end }}
2023-09-03 14:58:07 +02:00
- model: authentik_core.Application
id: {{ .Values.blueprint.application.name | default (include "authentik-application.fullname" .) }}
identifiers:
slug: {{ .Values.blueprint.application.slug }}
state: present
attrs:
name: {{ .Values.blueprint.application.name | default (include "authentik-application.fullname" .) }}
slug: {{ .Values.blueprint.application.slug }}
{{- if .Values.blueprint.provider.enabled }}
2023-09-03 14:58:07 +02:00
provider: !KeyOf {{ .Values.blueprint.provider.name | default (include "authentik-application.fullname" .) }}
{{- end }}
2023-09-03 14:58:07 +02:00
policy_engine_mode: {{ .Values.blueprint.application.policyEngineMode }}
{{- with .Values.blueprint.application.group }}
group: {{ . | quote }}
{{- end }}
{{- with .Values.blueprint.application.launchURL }}
meta_launch_url: {{ . | quote }}
{{- end }}
open_in_new_tab: {{ toYaml .Values.blueprint.application.openInNewTab }}
{{- with .Values.blueprint.application.icon }}
icon: {{ . | quote }}
2023-09-03 14:58:07 +02:00
{{- end }}
{{- with .Values.blueprint.application.description }}
meta_description: {{ . | quote }}
{{- end }}
{{- with .Values.blueprint.application.publisher }}
meta_publisher: {{ . | quote }}
{{- end }}
{{- if (eq (len .Values.blueprint.groups) 0) }}
- model: authentik_core.group
id: "app: {{ .Values.blueprint.application.slug }}"
identifiers:
name: "app: {{ .Values.blueprint.application.slug }}"
state: "present"
attrs:
name: "app: {{ .Values.blueprint.application.slug }}"
- model: authentik_policies.PolicyBinding
id: {{ printf "%s-app-%s" (include "authentik-application.fullname" .) .Values.blueprint.application.slug | quote }}
2023-09-03 14:58:07 +02:00
identifiers:
pk: {{ $bindPolicyID | quote }}
2023-09-03 14:58:07 +02:00
attrs:
group: !KeyOf "app: {{ .Values.blueprint.application.slug }}"
order: 10
target: !Find [authentik_core.Application, [slug, {{ .Values.blueprint.application.slug }}]]
{{- end }}
{{- range $group := .Values.blueprint.groups }}
2023-09-03 14:58:07 +02:00
- model: authentik_core.group
id: {{ $group.slug | quote }}
identifiers:
name: {{ $group.slug | quote }}
state: {{ $group.state | default "present" | quote }}
attrs:
name: {{ $group.slug | quote }}
{{- with $group.parent }}
parent: !Find [authentik_core.group, [name, {{ . | quote }}]]
{{- else}}
parent: null
{{- end }}
2023-09-03 14:58:07 +02:00
- model: authentik_policies.PolicyBinding
id: {{ printf "%s-app-%s" (include "authentik-application.fullname" $) $group.slug | quote }}
2023-09-03 14:58:07 +02:00
identifiers:
pk: {{ $group.bindID | quote }}
2023-09-03 14:58:07 +02:00
attrs:
group: !KeyOf {{ $group.slug | quote}}
order: 10
target: !Find [authentik_core.Application, [slug, {{ $.Values.blueprint.application.slug }}]]
{{- end }}