Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloud-native): secure mounted configuration schema #10577

Merged
merged 20 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5f5adb4
feat(cloud-native): secure mounted configuration schema
iromli Jan 5, 2025
6bf583b
feat(cloud-native): add support for configuration key file
iromli Jan 6, 2025
92780ba
feat(cloud-native): implement obfuscated configuration schema in high…
iromli Jan 7, 2025
446e216
chore(cloud-native): update JANS_SOURCE_VERSION
iromli Jan 8, 2025
efea007
docs(cloud-native): add missing configuration key docs
iromli Jan 8, 2025
c6bfe90
feat(cloud-native): add support for secure configuration schema in ja…
iromli Jan 8, 2025
53c4cd9
chore(cloud-native): cleanup unused template syntax
iromli Jan 8, 2025
931e9c6
refactor(jans-pycloudlib): revert temporary changes
iromli Jan 8, 2025
c819e09
docs(charts): mention about empty configuration key
iromli Jan 8, 2025
76030ca
Merge branch 'main' into cn-aes-conf-hilevel
moabu Jan 9, 2025
e3498fd
chore(cloud-native): update JANS_SOURCE_VERSION
iromli Jan 9, 2025
96a48bf
docs(kubernetes): fix example of using custom configuration schema
iromli Jan 9, 2025
ac4504f
chore(charts): specify allowed cnConfiguratorKey size
iromli Jan 10, 2025
324f50e
docs(kubernetes): add how-to section for encrypted configuration schema
iromli Jan 10, 2025
abe8fdd
docs: fix typos
misba7 Jan 13, 2025
4265f1a
docs: fix wording in values.yaml
misba7 Jan 13, 2025
252146a
docs: add the key used in custom schema
misba7 Jan 14, 2025
69d9ea1
Merge branch 'main' into cn-aes-conf-hilevel
iromli Jan 14, 2025
ca0b645
chore(cloud-native): update JANS_SOURCE_VERSION
iromli Jan 14, 2025
4d1da5d
Merge branch 'main' into cn-aes-conf-hilevel
moabu Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/janssen-all-in-one/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Kubernetes: `>=v1.22.0-0`
| cnConfiguratorCustomSchema | object | `{"secretName":""}` | Use custom configuration schema in existing secrets. Note, the secrets has to contain the key configuration.json or any basename as specified in cnConfiguratorConfigurationFile. |
| cnConfiguratorCustomSchema.secretName | string | `""` | The name of the secrets used for storing custom configuration schema. |
| cnConfiguratorDumpFile | string | `"/etc/jans/conf/configuration.out.json"` | Path to dumped configuration schema file |
| cnConfiguratorKey | string | `""` | Key to encrypt/decrypt configuration schema file using AES-256 CBC mode. Set the value to empty string to disable encryption/decryption, or 32 alphanumeric characters to enable it. |
| cnConfiguratorKeyFile | string | `"/etc/jans/conf/configuration.key"` | Path to file contains key to encrypt/decrypt configuration schema file. |
| cnDocumentStoreType | string | `"DB"` | Document store type to use for shibboleth files DB. |
| cnGoogleApplicationCredentials | string | `"/etc/jans/conf/google-credentials.json"` | Base64 encoded service account. The sa must have roles/secretmanager.admin to use Google secrets. Leave as this is a sensible default. |
| cnPersistenceType | string | `"sql"` | Persistence backend to run Janssen with hybrid|sql. |
Expand Down
72 changes: 69 additions & 3 deletions charts/janssen-all-in-one/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ Create optional scopes list
{{- define "janssen-all-in-one.optionalScopes"}}
{{ $newList := list }}
{{- if eq .Values.configmap.cnCacheType "REDIS" }}
{{ $newList = append $newList ("redis" | quote ) }}
{{ $newList = append $newList "redis" }}
{{- end}}
{{ if eq .Values.cnPersistenceType "sql" }}
{{ $newList = append $newList ("sql" | quote) }}
{{ $newList = append $newList "sql" }}
{{- end }}
{{ toJson $newList }}
{{- end }}
Expand Down Expand Up @@ -178,12 +178,78 @@ Create configuration schema-related objects.
{{- define "janssen-all-in-one.config.schema" -}}
{{- $commonName := (printf "%s-configuration-file" .Release.Name) -}}
{{- $secretName := .Values.cnConfiguratorCustomSchema.secretName | default $commonName -}}
{{- $keyName := (printf "%s-configuration-key-file" .Release.Name) -}}
volumes:
- name: {{ $commonName }}
secret:
secretName: {{ $secretName }}
{{- if .Values.cnConfiguratorKey }}
- name: {{ $keyName }}
secret:
secretName: {{ $keyName }}
{{- end }}
volumeMounts:
- name: {{ $commonName }}
mountPath: {{ .Values.cnConfiguratorConfigurationFile }}
subPath: {{ .Values.cnConfiguratorConfigurationFile | base }}
{{- end -}}
{{- if .Values.cnConfiguratorKey }}
- name: {{ $keyName }}
mountPath: {{ .Values.cnConfiguratorKeyFile }}
subPath: {{ .Values.cnConfiguratorKeyFile | base }}
{{- end }}
{{- end }}

{{/*
Obfuscate configuration schema (only if configuration key is available)
*/}}
{{- define "janssen-all-in-one.config.prepareSchema" }}

{{- $configmapSchema := dict }}
{{- $_ := set $configmapSchema "hostname" .Values.fqdn }}
{{- $_ := set $configmapSchema "country_code" .Values.countryCode }}
{{- $_ := set $configmapSchema "state" .Values.state }}
{{- $_ := set $configmapSchema "city" .Values.city }}
{{- $_ := set $configmapSchema "admin_email" .Values.email }}
{{- $_ := set $configmapSchema "orgName" .Values.orgName }}
{{- $_ := set $configmapSchema "auth_sig_keys" (index .Values "auth-server" "authSigKeys") }}
{{- $_ := set $configmapSchema "auth_enc_keys" (index .Values "auth-server" "authEncKeys") }}
{{- $_ := set $configmapSchema "optional_scopes" (include "janssen-all-in-one.optionalScopes" . | trim) }}
{{- if .Values.saml.enabled }}
{{- $_ := set $configmapSchema "kc_admin_username" .Values.configmap.kcAdminUsername }}
{{- end }}
{{- $_ := set $configmapSchema "init_keys_exp" (index .Values "auth-server-key-rotation" "initKeysLife") }}

{{- $secretSchema := dict }}
{{- $_ := set $secretSchema "admin_password" .Values.adminPassword }}
{{- $_ := set $secretSchema "redis_password" .Values.redisPassword }}
{{- if or ( eq .Values.cnPersistenceType "sql" ) ( eq .Values.cnPersistenceType "hybrid" ) }}
{{- $_ := set $secretSchema "sql_password" .Values.configmap.cnSqldbUserPassword }}
{{- end }}
{{- if eq .Values.configSecretAdapter "vault" }}
{{- $_ := set $secretSchema "vault_role_id" .Values.configmap.cnVaultRoleId }}
{{- $_ := set $secretSchema "vault_secret_id" .Values.configmap.cnVaultSecretId }}
{{- end }}
{{- if or (eq .Values.configSecretAdapter "google") (eq .Values.configAdapterName "google") }}
{{- $_ := set $secretSchema "google_credentials" .Values.configmap.cnGoogleSecretManagerServiceAccount }}
{{- end }}
{{- if or (eq .Values.configAdapterName "aws") (eq .Values.configSecretAdapter "aws") }}
{{- $_ := set $secretSchema "aws_credentials" (include "config.aws-shared-credentials" . | b64enc) }}
{{- $_ := set $secretSchema "aws_config" (include "config.aws-config" . | b64enc) }}
{{- $_ := set $secretSchema "aws_replica_regions" (toJson .Values.configmap.cnAwsSecretsReplicaRegions | b64enc) }}
{{- end }}
{{- if .Values.saml.enabled }}
{{- $_ := set $secretSchema "kc_db_password" .Values.configmap.kcDbPassword }}
{{- $_ := set $secretSchema "kc_admin_password" .Values.configmap.kcAdminPassword }}
{{- end }}
{{- $_ := set $secretSchema "encoded_salt" .Values.salt }}

{{- $schema := dict "_configmap" $configmapSchema "_secret" $secretSchema }}

{{- if .Values.cnConfiguratorKey }}
{{- printf "%s" (encryptAES .Values.cnConfiguratorKey (toPrettyJson $schema)) }}
{{- else -}}
{{- toPrettyJson $schema }}
{{- end }}

{{/* end of helpers */}}
{{- end }}
70 changes: 29 additions & 41 deletions charts/janssen-all-in-one/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,33 @@ metadata:
type: Opaque
stringData:
{{ .Values.cnConfiguratorConfigurationFile | base }}: |-
{
"_configmap": {
"hostname": {{ .Values.fqdn | quote }},
"country_code": {{ .Values.countryCode | quote }},
"state": {{ .Values.state | quote }},
"city": {{ .Values.city | quote }},
"admin_email": {{ .Values.email | quote }},
"orgName": {{ .Values.orgName | quote }},
"auth_sig_keys": {{ index .Values "auth-server" "authSigKeys" | quote }},
"auth_enc_keys": {{ index .Values "auth-server" "authEncKeys" | quote }},
"optional_scopes": {{ list (include "janssen-all-in-one.optionalScopes" . | fromJsonArray | join ",") | quote }},
{{- if .Values.saml.enabled }}
"kc_admin_username": {{ .Values.configmap.kcAdminUsername | quote }},
{{- end }}
"init_keys_exp": {{ index .Values "auth-server-key-rotation" "initKeysLife" }}
},
"_secret": {
"admin_password": {{ .Values.adminPassword | quote }},
"redis_password": {{ .Values.redisPassword | quote }},
{{ if or ( eq .Values.cnPersistenceType "sql" ) ( eq .Values.cnPersistenceType "hybrid" ) }}
"sql_password": {{ .Values.configmap.cnSqldbUserPassword | quote }},
{{- end }}
{{ if eq .Values.configSecretAdapter "vault" }}
"vault_role_id": {{ .Values.configmap.cnVaultRoleId | quote }},
"vault_secret_id": {{ .Values.configmap.cnVaultSecretId | quote }},
{{- end }}
{{ if or (eq .Values.configSecretAdapter "google") (eq .Values.configAdapterName "google") }}
"google_credentials": {{ .Values.configmap.cnGoogleSecretManagerServiceAccount | quote }},
{{- end }}
{{ if or (eq .Values.configAdapterName "aws") (eq .Values.configSecretAdapter "aws") }}
"aws_credentials": {{ include "janssen-all-in-one.aws-shared-credentials" . | b64enc | quote }},
"aws_config": {{ include "janssen-all-in-one.aws-config" . | b64enc | quote }},
"aws_replica_regions": {{ .Values.configmap.cnAwsSecretsReplicaRegions | toJson | b64enc | quote }},
{{- end }}
{{- if .Values.saml.enabled }}
"kc_db_password": {{ .Values.configmap.kcDbPassword | quote }},
"kc_admin_password": {{ .Values.configmap.kcAdminPassword | quote }},
{{- end }}
"encoded_salt": {{ .Values.salt | quote }}
}
}
{{ include "janssen-all-in-one.config.prepareSchema" . | indent 4 }}
{{- end }}

---

{{- if .Values.cnConfiguratorKey -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-configuration-key-file
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-{{ include "janssen-all-in-one.name" . }}-aio
{{ include "janssen-all-in-one.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
{{- if or (.Values.additionalAnnotations) (.Values.customAnnotations.secret) }}
annotations:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
{{- if .Values.customAnnotations.secret }}
{{ toYaml .Values.customAnnotations.secret | indent 4 }}
{{- end }}
{{- end }}
type: Opaque
data:
{{ .Values.cnConfiguratorKeyFile | base }}: {{ .Values.cnConfiguratorKey | b64enc }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/janssen-all-in-one/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ cnConfiguratorDumpFile: /etc/jans/conf/configuration.out.json
cnConfiguratorCustomSchema:
# -- The name of the secrets used for storing custom configuration schema.
secretName: ""
# -- Key to encrypt/decrypt configuration schema file using AES-256 CBC mode. Set the value to empty string to disable encryption/decryption, or 32 alphanumeric characters to enable it.
cnConfiguratorKey: ""
# -- Path to file contains key to encrypt/decrypt configuration schema file.
cnConfiguratorKeyFile: /etc/jans/conf/configuration.key

# ingress properties
istio:
Expand Down
Loading
Loading