Skip to content

Commit 06ca603

Browse files
authored
feat(platform): expose Keycloak truststores through platform values (#5144)
## What this PR does Fixes #5140. #5039 added `truststores` to the Keycloak chart, but that capability was not reachable through the administrator-owned platform Package: the system bundle rendered `Package cozystack.keycloak` without a components override. This PR adds the optional `authentication.oidc.keycloakTruststores` platform value and forwards it unchanged to `spec.components.keycloak.values.truststores` on that child Package. Administrators can configure it under `spec.components.platform.values` on `Package cozystack.cozystack-platform`: ```yaml authentication: oidc: keycloakTruststores: - configMapName: organization-ca key: ca.crt - secretName: partner-ca key: certificates.pem ``` When OIDC is enabled and the list is non-empty, the complete list is forwarded, including entry order, explicitly selected keys, and entries that omit `key` so the chart's `ca.crt` default remains effective. When the value is unset or explicitly empty, the platform continues to use the default Package helper without introducing `spec.components`. When OIDC is disabled, the value is ignored because no Keycloak Package is emitted. The platform layer only forwards references; it does not create Secrets or ConfigMaps. Referenced objects and keys must already exist in `cozy-keycloak`, and the Keycloak chart remains responsible for validation and mounting. Its existing semantics are unchanged: trust applies server-wide across all realms, only public certificate material should be supplied, and changing an object's contents requires a Keycloak restart or a versioned object reference to reload the truststore. ### Validation - `make test` in `packages/core/platform`: all 295 tests pass. The new suite covers unset, empty and null defaults, complete list forwarding, false-y malformed values, both `isp-full` and `isp-slim`, and disabled OIDC; removing the forwarding path or restoring truthiness-based empty checks makes the regression suite fail. - `make test` in `packages/system/keycloak`: all 121 tests pass. - With the system bundle and OIDC enabled, the unset render is byte-identical to `upstream/main`. The explicitly empty case is separately verified to omit `spec.components`; malformed false-y values reach the Keycloak chart and are rejected by its existing `truststores must be a list` validation. - `make generate` has no target in `packages/core/platform`; there are no generated platform schema artifacts to update. - `make show` could not run because `cozyhr` is unavailable. A direct `helm template` render of the system bundle was checked in a temporary chart copy with `templates/repository.yaml` removed because its `lookup` requires a live source. This verifies rendering and forwarding, not a live-cluster deployment or an end-to-end Keycloak TLS connection. ### Screenshots Not applicable; no UI changes. ### Downstream repositories Changing `packages/core/platform/values.yaml` directly triggers the website's hand-written platform-package reference. The existing cozystack/website#765 follow-up covers both the chart-level value and this platform configuration path, including `content/en/docs/next/operations/configuration/platform-package.md`; no other downstream trigger applies to this diff. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#765 (covers the platform value and platform-package reference as well as the chart-level guide) - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(platform): add `authentication.oidc.keycloakTruststores` so administrators can forward existing Secret or ConfigMap CA references from the platform Package to the bundled Keycloak server for private-CA LDAPS, external identity-provider, and SMTP TLS connections. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added the `authentication.oidc.keycloakTruststores` setting for configuring additional CA certificates from Secrets or ConfigMaps in `cozy-keycloak`. Certificate entries default to `ca.crt`, and configured certificates apply across all Keycloak realms. * The setting defaults to an empty list. Configured truststores are passed to Keycloak when OIDC is enabled; when OIDC is disabled, the setting is ignored and existing Keycloak package settings remain unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 233dee7 + 2a0dfa6 commit 06ca603

3 files changed

Lines changed: 226 additions & 0 deletions

File tree

‎packages/core/platform/templates/bundles/system.yaml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,19 @@
178178
{{- $controllerValues := dict "cozystackController" (dict "disableTelemetry" true) -}}
179179
{{- $_ := set $cozystackEngineComponents "cozystack-controller" (dict "values" $controllerValues) -}}
180180
{{- end -}}
181+
{{- $keycloakTruststores := .Values.authentication.oidc.keycloakTruststores -}}
182+
{{- $hasKeycloakTruststores := and (not (kindIs "invalid" $keycloakTruststores)) (or (not (kindIs "slice" $keycloakTruststores)) (not (empty $keycloakTruststores))) -}}
183+
{{- $keycloakComponents := dict -}}
184+
{{- if $hasKeycloakTruststores }}
185+
{{- $_ := set $keycloakComponents "keycloak" (dict "values" (dict "truststores" $keycloakTruststores)) -}}
186+
{{- end }}
181187
{{- if .Values.authentication.oidc.enabled }}
182188
{{include "cozystack.platform.package" (list "cozystack.cozystack-engine" "oidc" $ $cozystackEngineComponents) }}
189+
{{- if $hasKeycloakTruststores }}
190+
{{include "cozystack.platform.package" (list "cozystack.keycloak" "default" $ $keycloakComponents) }}
191+
{{- else }}
183192
{{include "cozystack.platform.package.default" (list "cozystack.keycloak" $) }}
193+
{{- end }}
184194
{{include "cozystack.platform.package.default" (list "cozystack.keycloak-operator" $) }}
185195
{{- else }}
186196
{{include "cozystack.platform.package" (list "cozystack.cozystack-engine" "default" $ $cozystackEngineComponents) }}
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
suite: bundles.system Keycloak truststores wiring
2+
templates:
3+
- templates/bundles/system.yaml
4+
release:
5+
name: cozystack
6+
namespace: cozy-system
7+
tests:
8+
- it: emits cozystack.keycloak without a components block when keycloakTruststores is unset
9+
set:
10+
bundles:
11+
system:
12+
enabled: true
13+
variant: isp-full
14+
authentication:
15+
oidc:
16+
enabled: true
17+
documentSelector:
18+
path: metadata.name
19+
value: cozystack.keycloak
20+
asserts:
21+
- equal:
22+
path: kind
23+
value: Package
24+
- equal:
25+
path: spec.variant
26+
value: default
27+
- notExists:
28+
path: spec.components
29+
30+
- it: omits the components block when keycloakTruststores is explicitly empty
31+
set:
32+
bundles:
33+
system:
34+
enabled: true
35+
variant: isp-full
36+
authentication:
37+
oidc:
38+
enabled: true
39+
keycloakTruststores: []
40+
documentSelector:
41+
path: metadata.name
42+
value: cozystack.keycloak
43+
asserts:
44+
- notExists:
45+
path: spec.components
46+
47+
- it: omits the components block when keycloakTruststores is explicitly null
48+
set:
49+
bundles:
50+
system:
51+
enabled: true
52+
variant: isp-full
53+
authentication:
54+
oidc:
55+
enabled: true
56+
keycloakTruststores: null
57+
documentSelector:
58+
path: metadata.name
59+
value: cozystack.keycloak
60+
asserts:
61+
- notExists:
62+
path: spec.components
63+
64+
- it: forwards false so the Keycloak chart can reject it instead of silently removing trust
65+
set:
66+
bundles:
67+
system:
68+
enabled: true
69+
variant: isp-full
70+
authentication:
71+
oidc:
72+
enabled: true
73+
keycloakTruststores: false
74+
documentSelector:
75+
path: metadata.name
76+
value: cozystack.keycloak
77+
asserts:
78+
- equal:
79+
path: spec.components.keycloak.values.truststores
80+
value: false
81+
82+
- it: forwards zero so the Keycloak chart can reject it instead of silently removing trust
83+
set:
84+
bundles:
85+
system:
86+
enabled: true
87+
variant: isp-full
88+
authentication:
89+
oidc:
90+
enabled: true
91+
keycloakTruststores: 0
92+
documentSelector:
93+
path: metadata.name
94+
value: cozystack.keycloak
95+
asserts:
96+
- equal:
97+
path: spec.components.keycloak.values.truststores
98+
value: 0
99+
100+
- it: forwards an empty string so the Keycloak chart can reject it instead of silently removing trust
101+
set:
102+
bundles:
103+
system:
104+
enabled: true
105+
variant: isp-full
106+
authentication:
107+
oidc:
108+
enabled: true
109+
keycloakTruststores: ""
110+
documentSelector:
111+
path: metadata.name
112+
value: cozystack.keycloak
113+
asserts:
114+
- equal:
115+
path: spec.components.keycloak.values.truststores
116+
value: ""
117+
118+
- it: forwards an empty map so the Keycloak chart can reject it instead of silently removing trust
119+
set:
120+
bundles:
121+
system:
122+
enabled: true
123+
variant: isp-full
124+
authentication:
125+
oidc:
126+
enabled: true
127+
keycloakTruststores: {}
128+
documentSelector:
129+
path: metadata.name
130+
value: cozystack.keycloak
131+
asserts:
132+
- equal:
133+
path: spec.components.keycloak.values.truststores
134+
value: {}
135+
136+
- it: forwards the complete truststores list without taking over chart defaults
137+
set:
138+
bundles:
139+
system:
140+
enabled: true
141+
variant: isp-full
142+
authentication:
143+
oidc:
144+
enabled: true
145+
keycloakTruststores:
146+
- configMapName: organization-ca
147+
- secretName: partner-ca
148+
key: certificates.pem
149+
- configMapName: secondary-ca
150+
key: chain.pem
151+
documentSelector:
152+
path: metadata.name
153+
value: cozystack.keycloak
154+
asserts:
155+
- equal:
156+
path: spec.components.keycloak.values
157+
value:
158+
truststores:
159+
- configMapName: organization-ca
160+
- secretName: partner-ca
161+
key: certificates.pem
162+
- configMapName: secondary-ca
163+
key: chain.pem
164+
165+
- it: forwards keycloakTruststores on the isp-slim variant too
166+
set:
167+
bundles:
168+
system:
169+
enabled: true
170+
variant: isp-slim
171+
authentication:
172+
oidc:
173+
enabled: true
174+
keycloakTruststores:
175+
- configMapName: organization-ca
176+
key: ca.crt
177+
documentSelector:
178+
path: metadata.name
179+
value: cozystack.keycloak
180+
asserts:
181+
- equal:
182+
path: spec.components.keycloak.values.truststores
183+
value:
184+
- configMapName: organization-ca
185+
key: ca.crt
186+
187+
- it: does not emit cozystack.keycloak for a malformed false-y value when OIDC is disabled
188+
set:
189+
bundles:
190+
system:
191+
enabled: true
192+
variant: isp-full
193+
authentication:
194+
oidc:
195+
enabled: false
196+
keycloakTruststores: false
197+
asserts:
198+
- containsDocument:
199+
apiVersion: cozystack.io/v1alpha1
200+
kind: Package
201+
name: cozystack.keycloak
202+
any: true
203+
not: true

‎packages/core/platform/values.yaml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,19 @@ authentication:
549549
# OIDC discovery; any other value -> used verbatim. An explicit value is not rewritten, so a
550550
# custom realm paired with an explicit URL must name the same realm.
551551
keycloakInternalUrl: null
552+
# Additional CA trust anchors for the bundled Keycloak server (LDAPS,
553+
# external IdPs, SMTP). Each entry selects one key from an existing Secret
554+
# or ConfigMap in cozy-keycloak; key defaults to ca.crt. Trust applies to
555+
# the entire server across all realms. See packages/system/keycloak/values.yaml
556+
# for supported formats, incoming-client-mTLS scope and rotation behavior.
557+
# Ignored when oidc.enabled is false: no Keycloak Package is emitted. An
558+
# existing Package and its rendered truststores remain on the cluster
559+
# (helm.sh/resource-policy: keep).
560+
keycloakTruststores: []
561+
# - configMapName: organization-ca
562+
# key: ca.crt
563+
# - secretName: partner-ca
564+
# key: certificates.pem
552565
# Gateway API configuration
553566
gateway:
554567
# Enable Gateway API support across the platform. When true:

0 commit comments

Comments
 (0)