Files
cozystack/packages
scooby87 176dd78c1a feat(dashboard): serve console branding without kube-api access (#4256)
## What this PR does

Part of #4217. 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 it 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. (The unauthenticated login page is a separate surface,
branded in #4255.)

This mounts that ConfigMap read-only under the nginx web root and serves
it at `/branding/config.json`, and reads 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, it is restricted 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` is exposed under the web root.

Verified with `pnpm typecheck`, `pnpm test` (7 `loadConfig` cases),
`eslint`, and `helm unittest` (mount + `items`, the `config.json` key
the mount serves, white-label keys kept incl. `tenantText`,
Keycloak-only keys absent). Also validated live on a dev cluster:
`console-rbac.yaml` binds the ConfigMap read to `system:authenticated`
(`kubectl auth can-i get` this CM as an unbound user → yes; another CM →
no), and a throwaway pod on the real console image serving the mounted
ConfigMap returns `200 application/json` at `/branding/config.json`
while an `items`-excluded key falls through to `index.html`.

### Screenshots

No visual regression to show in a static render: this changes where the
branding config is fetched from, not how it is displayed.

### Downstream repositories

The diff touches only `packages/system/dashboard` (the in-repo console
image and its chart). No app is added, renamed or removed, no
`values.schema.json` / enum / default changes, no CRD or namespace
changes, and the branding keys the SPA reads are unchanged — only the
transport (static asset vs kube-api) and a narrowing of which keys are
served. Nothing in the trigger map applies.

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[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(dashboard): the console serves its branding as a static asset (`/branding/config.json`) read with no kube-api call, so branding renders even when the apiserver does not authenticate the session and without the console-config-reader RBAC; the served file is narrowed to the documented white-labeling keys.
```
2026-09-22 18:36:47 +03:00
..