mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 20:23:39 +09:00
The dashboard branding (title, logo) lives in the cozy-dashboard-console-config ConfigMap, which the SPA reaches only through the authenticated kube-api. The token-proxy login page — the first screen an unauthenticated user sees on a non-OIDC cluster — had no access to it and rendered the hardcoded default title and heading, defeating branding for customer-facing deployments. Mount that ConfigMap read-only into the token-proxy container and render its titleText, logoText and logoSvg on the login page, falling back to the historical unbranded page when the file is absent or unreadable so a cluster without branding is unaffected. logoSvg is already base64 in the config — the SPA's Logo.tsx consumes it that way — so it is served verbatim through an <img> data URI, never re-encoded, which keeps any embedded script inert. The OIDC branch is untouched: its login is served by Keycloak, already branded through the realm theme. Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
288 lines
13 KiB
YAML
288 lines
13 KiB
YAML
suite: gatekeeper container and probes per OIDC mode
|
|
templates:
|
|
- templates/gatekeeper.yaml
|
|
|
|
release:
|
|
name: dashboard
|
|
namespace: cozy-dashboard
|
|
|
|
# gatekeeper.yaml selects between two completely different containers
|
|
# depending on _cluster.oidc-enabled: the OIDC-enabled branch runs
|
|
# oauth2-proxy (image quay.io/oauth2-proxy/oauth2-proxy) which serves
|
|
# /ping as a health endpoint, and the OIDC-disabled branch runs the
|
|
# in-tree token-proxy which serves /healthz/live + /healthz/ready.
|
|
# Each branch has its own probes; a refactor that collapses the
|
|
# if/else differently (e.g. shared probes on /ping) would silently
|
|
# break the OIDC-disabled deployment because token-proxy does not
|
|
# answer /ping with a 2xx. Pin both branches so structural drift is
|
|
# a test failure.
|
|
|
|
tests:
|
|
- it: oidc-enabled=false renders token-proxy with /healthz probes
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "false"
|
|
tokenProxy:
|
|
image: example.invalid/token-proxy:test
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.containers[0].name
|
|
value: token-proxy
|
|
- equal:
|
|
path: spec.template.spec.containers[0].image
|
|
value: example.invalid/token-proxy:test
|
|
- equal:
|
|
path: spec.template.spec.containers[0].startupProbe.httpGet.path
|
|
value: /healthz/ready
|
|
- equal:
|
|
path: spec.template.spec.containers[0].startupProbe.failureThreshold
|
|
value: 30
|
|
- equal:
|
|
path: spec.template.spec.containers[0].startupProbe.periodSeconds
|
|
value: 10
|
|
- equal:
|
|
path: spec.template.spec.containers[0].livenessProbe.httpGet.path
|
|
value: /healthz/live
|
|
- equal:
|
|
path: spec.template.spec.containers[0].readinessProbe.httpGet.path
|
|
value: /healthz/ready
|
|
- equal:
|
|
path: spec.template.spec.containers[0].ports[0].containerPort
|
|
value: 8000
|
|
# The pre-auth login page reads its branding from the same
|
|
# cozy-dashboard-console-config ConfigMap the SPA consumes, mounted
|
|
# read-only. The volume is optional so a cluster without branding still
|
|
# starts and renders the historical unbranded page.
|
|
- equal:
|
|
path: spec.template.spec.containers[0].volumeMounts[0].name
|
|
value: branding
|
|
- equal:
|
|
path: spec.template.spec.containers[0].volumeMounts[0].mountPath
|
|
value: /etc/cozystack/branding
|
|
- equal:
|
|
path: spec.template.spec.containers[0].volumeMounts[0].readOnly
|
|
value: true
|
|
- contains:
|
|
path: spec.template.spec.volumes
|
|
content:
|
|
name: branding
|
|
configMap:
|
|
name: cozy-dashboard-console-config
|
|
optional: true
|
|
|
|
# The OIDC branch runs oauth2-proxy, whose login is served by Keycloak (already
|
|
# branded via the realm theme), so the branding ConfigMap must not be mounted
|
|
# there — pin its absence so a refactor that hoists the volume out of the
|
|
# non-OIDC guard is a test failure.
|
|
- it: oidc-enabled=true does not mount the branding config
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "true"
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.volumes
|
|
- notExists:
|
|
path: spec.template.spec.containers[0].volumeMounts
|
|
|
|
# authentication.oidc.enabled defaults to false while keycloakInternalUrl now
|
|
# defaults to the in-cluster Service, so THIS pair — OIDC off, internal URL
|
|
# set — is what most clusters actually render. The internal-URL block is
|
|
# nested inside the oidc-enabled guard, so it cannot leak into the
|
|
# token-proxy branch today; pin that, because a refactor which hoists the
|
|
# block out would otherwise ship silently.
|
|
- it: oidc-enabled=false ignores a set keycloak-internal-url
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "false"
|
|
keycloak-internal-url: http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy
|
|
tokenProxy:
|
|
image: example.invalid/token-proxy:test
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.containers[0].name
|
|
value: token-proxy
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --skip-oidc-discovery
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --redeem-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/token
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-jwks-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/certs
|
|
|
|
- it: oidc-enabled=true renders auth-proxy with /ping probes and no startupProbe
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "true"
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.containers[0].name
|
|
value: auth-proxy
|
|
- matchRegex:
|
|
path: spec.template.spec.containers[0].image
|
|
pattern: "^quay\\.io/oauth2-proxy/oauth2-proxy:"
|
|
- equal:
|
|
path: spec.template.spec.containers[0].livenessProbe.httpGet.path
|
|
value: /ping
|
|
- equal:
|
|
path: spec.template.spec.containers[0].readinessProbe.httpGet.path
|
|
value: /ping
|
|
- notExists:
|
|
path: spec.template.spec.containers[0].startupProbe
|
|
- equal:
|
|
path: spec.template.spec.containers[0].ports[0].containerPort
|
|
value: 8000
|
|
|
|
# keycloak-internal-url arrives on the _cluster channel from
|
|
# authentication.oidc.keycloakInternalUrl in packages/core/platform. Its
|
|
# default is the in-cluster Keycloak Service, so the value asserted below is
|
|
# what a stock cluster ships: oauth2-proxy skips OIDC discovery and talks to
|
|
# the Service for token/jwks/userinfo/logout, which keeps the dashboard
|
|
# independent of the root ingress serving keycloak.<host> at startup. The
|
|
# browser-facing URLs (redirect, login) must stay on the external host —
|
|
# routing them to a cluster-internal address would send the user's browser to
|
|
# an unreachable URL.
|
|
- it: default in-cluster keycloak URL skips discovery and keeps browser URLs external
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "true"
|
|
keycloak-internal-url: http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --skip-oidc-discovery
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --redeem-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/token
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-jwks-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/certs
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --validate-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/userinfo
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --backend-logout-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/logout?id_token_hint={id_token}
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --redirect-url=https://dashboard.example.org/oauth2/callback
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --login-url=https://keycloak.example.org/realms/cozy/protocol/openid-connect/auth
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-issuer-url=https://keycloak.example.org/realms/cozy
|
|
|
|
- it: an explicit keycloak-internal-url override wins over the default
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "true"
|
|
keycloak-internal-url: http://keycloak.example.test:8080/realms/other
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --skip-oidc-discovery
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --redeem-url=http://keycloak.example.test:8080/realms/other/protocol/openid-connect/token
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-jwks-url=http://keycloak.example.test:8080/realms/other/protocol/openid-connect/certs
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --validate-url=http://keycloak.example.test:8080/realms/other/protocol/openid-connect/userinfo
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --redeem-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/token
|
|
|
|
# The escape hatch: an operator who sets keycloakInternalUrl back to "" gets
|
|
# the historical shape — full OIDC discovery against the external issuer, no
|
|
# backend URLs pinned. It must keep working, so pin it.
|
|
#
|
|
# --skip-oidc-discovery carries the whole meaning here. All five in-cluster
|
|
# args live inside one {{- if $keycloakInternalUrl }} block in the template,
|
|
# so its absence structurally guarantees the absence of the other four; the
|
|
# notContains assertions below then pin the regression that actually threatens
|
|
# this branch — the in-cluster default leaking back in. Asserting an arg count
|
|
# instead would couple this OIDC test to every unrelated gatekeeper flag.
|
|
- it: empty keycloak-internal-url restores external OIDC discovery
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "true"
|
|
keycloak-internal-url: ""
|
|
asserts:
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --skip-oidc-discovery
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-issuer-url=https://keycloak.example.org/realms/cozy
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --backend-logout-url=https://keycloak.example.org/realms/cozy/protocol/openid-connect/logout?id_token_hint={id_token}
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --redeem-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/token
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-jwks-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/certs
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --validate-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/userinfo
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --backend-logout-url=http://keycloak-http.cozy-keycloak.svc:8080/realms/cozy/protocol/openid-connect/logout?id_token_hint={id_token}
|
|
|
|
# The realm segment of the browser-facing issuer/login/logout URLs is driven
|
|
# by _cluster.oidc-realm-name (authentication.oidc.realmName in the platform).
|
|
# A renamed realm must reach every one of them; a URL left on the literal
|
|
# "cozy" would send the browser to a realm the apiserver OIDC issuer no longer
|
|
# matches, silently breaking SSO.
|
|
- it: threads a custom realm name through the browser-facing OIDC URLs
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "true"
|
|
oidc-realm-name: acme
|
|
keycloak-internal-url: http://keycloak-http.cozy-keycloak.svc:8080/realms/acme
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-issuer-url=https://keycloak.example.org/realms/acme
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --login-url=https://keycloak.example.org/realms/acme/protocol/openid-connect/auth
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --oidc-issuer-url=https://keycloak.example.org/realms/cozy
|
|
|
|
# The external-discovery branch (empty internal URL) builds its own
|
|
# backend-logout-url on the browser host, so the realm segment there must
|
|
# follow oidc-realm-name too; reverting $realm in that branch alone would
|
|
# otherwise survive the suite.
|
|
- it: threads a custom realm into the external-discovery logout URL
|
|
set:
|
|
_cluster:
|
|
root-host: example.org
|
|
oidc-enabled: "true"
|
|
oidc-realm-name: acme
|
|
keycloak-internal-url: ""
|
|
asserts:
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --skip-oidc-discovery
|
|
- contains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --backend-logout-url=https://keycloak.example.org/realms/acme/protocol/openid-connect/logout?id_token_hint={id_token}
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].args
|
|
content: --backend-logout-url=https://keycloak.example.org/realms/cozy/protocol/openid-connect/logout?id_token_hint={id_token}
|