Skip to content

Commit ea5da8b

Browse files
committed
fix(platform): reject an empty realm name instead of coercing it to cozy
realmName resolved through `| default "cozy"`, which fires on both null and "". Unset (null) legitimately means the default, but an explicit "" is a meaningless value and coercing it hid the mistake. Split the two: null falls back to cozy, an empty string reaches the charset guard and is rejected — the same null-vs-"" distinction keycloakInternalUrl already draws a few lines below. Assisted-by: LLM Signed-off-by: Alexey Artamonov <[email protected]>
1 parent c0fc12a commit ea5da8b

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎packages/core/platform/templates/apps.yaml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,14 @@ stringData:
116116
rather than emit a broken issuer later. The hint does not echo the
117117
parsed value back: YAML has already lost the operator's original
118118
token (on -> true), so quoting is the fix, not the reprinted bool. */}}
119-
{{- $realmName := .Values.authentication.oidc.realmName | default "cozy" }}
119+
{{- /* Unset (null) falls back to cozy; an explicit "" is a meaningless
120+
value, not a default request, so let it reach the charset guard
121+
below rather than swallowing it — mirrors the keycloakInternalUrl
122+
tri-state a few lines down (kindIs "invalid" is null, not ""). */}}
123+
{{- $realmName := .Values.authentication.oidc.realmName }}
124+
{{- if kindIs "invalid" $realmName }}
125+
{{- $realmName = "cozy" }}
126+
{{- end }}
120127
{{- if not (kindIs "string" $realmName) }}
121128
{{- fail (printf "authentication.oidc.realmName must be a string (got %s); wrap the value in quotes in the platform values, e.g. realmName: \"my-realm\"" (kindOf $realmName)) }}
122129
{{- end }}

‎packages/core/platform/tests/apps_oidc_realm_name_test.yaml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ tests:
2121
path: stringData["values.yaml"]
2222
pattern: 'oidc-realm-name:\s*"cozy"'
2323

24+
# Unset (null) falls back to cozy, but an explicit empty string is a
25+
# meaningless value, not a request for the default — it is rejected by the
26+
# charset guard rather than silently coerced, mirroring the null-vs-"" tristate
27+
# of keycloakInternalUrl below.
28+
- it: rejects an explicitly empty realm name
29+
set:
30+
authentication.oidc.realmName: ""
31+
asserts:
32+
- failedTemplate:
33+
errorMessage: 'authentication.oidc.realmName "" is invalid: use only letters, digits, ''.'', ''_'' and ''-'' (it is used verbatim as a URL path segment and a shell token)'
34+
2435
- it: propagates a custom realm name onto the _cluster channel
2536
set:
2637
authentication.oidc.realmName: acme

0 commit comments

Comments
 (0)