mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-01 20:56:02 +09:00
The SPA fetched its branding (title, logo) only by reading the cozy-dashboard-console-config ConfigMap through the kube-api. That read already works for any signed-in user — console-rbac.yaml binds get on that ConfigMap to system:authenticated — but it still depends on the kube-api being reachable and on the apiserver authenticating the session's token. A dashboard login whose token the apiserver rejects (an OIDC session the kube-api does not accept) gets no branding at all. Mount that ConfigMap read-only under the nginx web root and serve it at /branding/config.json, and read that static asset first in loadConfig, falling back to the kube-api ConfigMap for charts that predate the mount (their static path serves the SPA index.html, whose non-JSON body trips the fallback). Branding then resolves with no kube-api call at all, so it renders regardless of whether the apiserver authenticates the session and without the console-config-reader RBAC. Because config.json is now a static asset reachable by anyone past the proxy, restrict it to the documented white-labeling keys: the branding map also carries Keycloak-only keys, including loginThemeImage, which can point at a private registry. Keycloak reads those from _cluster.branding directly. The mount uses an items selector so only config.json, not any other key the ConfigMap may grow, is exposed under the web root. Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
30 lines
1.7 KiB
YAML
30 lines
1.7 KiB
YAML
{{- $branding := .Values._cluster.branding | default dict }}
|
|
{{- /* Surface the platform version to the SPA at deploy time, derived from the
|
|
console image tag (build stamps it vX.Y.Z; promotion rewrites rc->stable).
|
|
This decouples the displayed version from the VITE_APP_VERSION baked into
|
|
the bundle, so a promoted-by-retag image reports the stable version. */}}
|
|
{{- $tag := .Values.console.image | toString | splitList "@" | first | splitList ":" | last }}
|
|
{{- /* Serve only the console's white-labeling keys — documented in the website
|
|
white-labeling guide (recorded here in docs/changelogs/v1.0.3.md) and
|
|
typed as AppConfig in images/console/.../lib/config.ts. pick is an
|
|
allow-list, so the Keycloak branding keys (brandName, brandHtmlName,
|
|
loginTheme, loginThemeImage — the last an OCI reference that may point at
|
|
a private registry) are dropped: this config.json is now a static asset
|
|
reachable by anyone past the proxy, and Keycloak reads its keys from
|
|
_cluster.branding directly. */}}
|
|
{{- $config := pick $branding "titleText" "tenantText" "footerText" "logoText" "logoSvg" "iconSvg" }}
|
|
{{- /* Require digits then a dot (v1.5.0 / 1.5.0), so a tagless ref whose last
|
|
":"-segment is a repo path with a port (ghcr.io:443/.../console -> last
|
|
"443/.../console") does not get mistaken for a version. */}}
|
|
{{- if regexMatch "^v?[0-9]+\\." $tag }}
|
|
{{- /* Keep the tag verbatim (vX.Y.Z), matching the operator's COZYSTACK_VERSION
|
|
and the vX.Y.Z release tags, rather than stripping the leading v. */}}
|
|
{{- $_ := set $config "version" $tag }}
|
|
{{- end }}
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: cozy-dashboard-console-config
|
|
data:
|
|
config.json: {{ $config | toJson | quote }}
|