Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/brand.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ repository. Each page embeds the files it needs in its own ConfigMap:

- Dex: [`dex-theme`](../k8s/bases/infrastructure/controllers/dex/config-map.yaml) holds
`favicon.png` (the icon at 256 px) and `logo.svg` (the dark-background wordmark).
- The customer Dex (login.devantler.tech):
[`customer-dex-theme`](../k8s/providers/hetzner/apps/customer-identity/config-map-dex-theme.yaml)
is a copy of `dex-theme` with only its name and namespace changed;
`scripts/tests/test-dex-theme-mount.sh` fails when the two differ.
- Homepage: [`homepage-brand`](../k8s/bases/apps/homepage/config-map-brand.yaml) holds the icon at
180, 192 and 512 px and as `icon.svg`.
- ZITADEL (accounts.devantler.tech and its emails):
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,19 @@ spec:
items:
- key: ca.crt
path: ca.crt
# The Devantler Tech theme (config-map-dex-theme.yaml).
- name: theme
configMap:
name: customer-dex-theme
volumeMounts:
- name: tmp
mountPath: /tmp
- name: db-ca
mountPath: /db-ca
readOnly: true
- name: theme
mountPath: /srv/dex/web/themes/devantler-tech
readOnly: true
envVars:
# Refuse to start with a broken connector instead of serving without it.
- name: DEX_CONTINUE_ON_CONNECTOR_FAILURE
Expand All @@ -119,8 +126,13 @@ spec:
key: client-secret
config:
issuer: https://login.devantler.tech
# The Devantler Tech theme, as on the platform Dex: the wordmark as the
# header, served from the cluster (config-map-dex-theme.yaml).
frontend:
issuer: Devantler Tech
dir: /srv/dex/web
theme: devantler-tech
logoURL: theme/logo.svg
storage:
type: postgres
config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ spec:
hostnames:
- login.devantler.tech
rules:
# The theme (config-map-dex-theme.yaml) is served at stable URLs, so no
# shared or browser cache may keep it after a change: Cloudflare otherwise
# holds it for four hours, as it did on the platform Dex.
- matches:
- path:
type: PathPrefix
value: /theme/
filters:
- type: ResponseHeaderModifier
responseHeaderModifier:
set:
- name: Strict-Transport-Security
value: max-age=63072000; includeSubDomains; preload
- name: Cache-Control
value: private, no-store
backendRefs:
- name: customer-dex
port: 5556
- filters:
- type: ResponseHeaderModifier
responseHeaderModifier:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ resources:
- database-dex.yaml
- external-secret-dex-portal-client.yaml
- helm-repository-dex.yaml
- config-map-dex-theme.yaml
- helm-release-dex.yaml
- http-route-dex.yaml
- cilium-network-policy.yaml
Expand Down
43 changes: 38 additions & 5 deletions scripts/tests/test-dex-theme-mount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
# A logoURL outside theme/ would load the logo from somewhere other than this
# cluster, so it is refused.
#
# The customer Dex (customer-identity/customer-dex, in the Hetzner apps layer)
# carries the same theme and gets the same checks, and its theme files must equal
# the platform Dex's byte for byte.
#
# Every check is first run against a broken copy of the real render, to prove
# it fails for the reason it names.
set -euo pipefail
Expand All @@ -37,7 +41,10 @@ fail() {
exit 1
}

readonly dex_release='select(.kind == "HelmRelease" and .metadata.name == "dex" and .metadata.namespace == "dex")'
# The release under check: DEX_NAME in namespace DEX_NS (the platform Dex unless
# a case sets them).
export DEX_NAME=dex DEX_NS=dex
readonly dex_release='select(.kind == "HelmRelease" and .metadata.name == strenv(DEX_NAME) and .metadata.namespace == strenv(DEX_NS))'

# read_yaml <expression> <file>: one yq read, or a printed reason and status 1.
# Reads are checked one by one so that a failed read is never taken for an
Expand Down Expand Up @@ -67,7 +74,7 @@ check_theme() {
return 1
}
if [[ "${count}" != 1 ]]; then
printf 'renders %s dex HelmReleases in namespace dex instead of one\n' "${count:-no}"
printf 'renders %s %s HelmReleases in namespace %s instead of one\n' "${count:-no}" "${DEX_NAME}" "${DEX_NS}"
return 1
fi
values="${workdir}/dex-values.yaml"
Expand Down Expand Up @@ -150,13 +157,13 @@ check_theme() {
return 1
fi

local -r configmap="select(.kind == \"ConfigMap\" and .metadata.name == strenv(CM) and .metadata.namespace == \"dex\")"
local -r configmap="select(.kind == \"ConfigMap\" and .metadata.name == strenv(CM) and .metadata.namespace == strenv(DEX_NS))"
count="$(CM="${cm_name}" read_all "[${configmap}] | length" "${rendered}")" || {
printf '%s\n' "${count}"
return 1
}
if [[ "${count}" != 1 ]]; then
printf "the ConfigMap '%s' that the theme is mounted from is rendered %s times in namespace dex in this layer instead of once\n" "${cm_name}" "${count}"
printf "the ConfigMap '%s' that the theme is mounted from is rendered %s times in namespace %s in this layer instead of once\n" "${cm_name}" "${count}" "${DEX_NS}"
return 1
fi

Expand Down Expand Up @@ -250,5 +257,31 @@ for provider in "${providers[@]}"; do
fail "${provider}: ${out}. The Dex theme is configured in k8s/bases/infrastructure/controllers/dex/ (helm-release.yaml and config-map.yaml)"
done

printf 'PASS: on %s, Dex is told to use the theme directory its ConfigMap is mounted at, and that theme holds every file the pages link to\n' \
# --- The customer Dex (Hetzner apps layer) --------------------------------------
kubectl kustomize "${repo_root}/k8s/providers/hetzner/apps" >"${workdir}/apps.yaml" 2>"${workdir}/render.err" ||
fail "k8s/providers/hetzner/apps failed to build: $(tail -5 "${workdir}/render.err")"
export DEX_NAME=customer-dex DEX_NS=customer-identity
yq eval "select((.kind == \"ConfigMap\" and .metadata.name == \"customer-dex-theme\") | not)" "${workdir}/apps.yaml" >"${broken}"
expect_failure 'customer Dex ConfigMap missing' "${broken}" 'rendered 0 times'
out="$(check_theme "${workdir}/apps.yaml")" ||
fail "customer Dex: ${out}. Its theme is configured in k8s/providers/hetzner/apps/customer-identity/ (helm-release-dex.yaml and config-map-dex-theme.yaml)"

# themes_equal <controllers.yaml> <apps.yaml>: the customer Dex's theme is a copy
# of the platform Dex's, so their files must be equal byte for byte.
themes_equal() {
local -r files='{"data": .data, "binaryData": .binaryData}'
local platform customer
platform="$(yq eval -o=json -I=0 "select(.kind == \"ConfigMap\" and .metadata.name == \"dex-theme\") | ${files}" "$1")" || return 1
customer="$(yq eval -o=json -I=0 "select(.kind == \"ConfigMap\" and .metadata.name == \"customer-dex-theme\") | ${files}" "$2")" || return 1
[[ -n "${platform}" && "${platform}" == "${customer}" ]]
}
yq eval '(select(.kind == "ConfigMap" and .metadata.name == "customer-dex-theme") | .data["styles.css"]) += "/* drift */"' \
"${workdir}/apps.yaml" >"${broken}"
if themes_equal "${workdir}/hetzner.yaml" "${broken}"; then
fail "control 'customer Dex theme drifted': the equality check passed a changed stylesheet"
fi
themes_equal "${workdir}/hetzner.yaml" "${workdir}/apps.yaml" ||
fail "the customer Dex theme (customer-identity/config-map-dex-theme.yaml) differs from the platform Dex theme (dex/config-map.yaml); keep the two equal"

printf 'PASS: on %s and for the customer Dex (whose theme equals the platform Dex theme), Dex is told to use the theme directory its ConfigMap is mounted at, and that theme holds every file the pages link to\n' \
"${providers[*]}"
2 changes: 1 addition & 1 deletion scripts/validate-eks-ci-role-policy/approved-surface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ helm.toolkit.fluxcd.io/v2|HelmRelease|cnpg-system|plugin-barman-cloud 74682cb45a

helm.toolkit.fluxcd.io/v2|HelmRelease|crossplane-system|crossplane fb717f7c9adb21b0f772e6a84554900e568a2675c91d375d1bb6ee76c2a0b1f3

helm.toolkit.fluxcd.io/v2|HelmRelease|customer-identity|customer-dex 55a9ceabb55c712138a754c1666cf9e55b62b47357e3ac3cddea423a17531051
helm.toolkit.fluxcd.io/v2|HelmRelease|customer-identity|customer-dex 4c568faea9557d01783d606255b6aab07af01519caeca91a8349f62ceff873f5

helm.toolkit.fluxcd.io/v2|HelmRelease|customer-identity|zitadel eeb9881018664637cdefc9c5c0afd6953aa958e5dbfbc9cd8c5d521501e52431

Expand Down
Loading