diff --git a/scripts/run-compose-runtime-smoke.sh b/scripts/run-compose-runtime-smoke.sh index c07b5e8e..2f2033f2 100755 --- a/scripts/run-compose-runtime-smoke.sh +++ b/scripts/run-compose-runtime-smoke.sh @@ -83,6 +83,8 @@ done # The lane-only TLS overlay's keypair directory (src/bootstrap/app/compose-lanes/tls.yaml). LANE_POSTGRES_TLS="${REPO_ROOT}/src/bootstrap/app/compose-lanes/postgres/tls" +# The user quay.io/keycloak/keycloak runs as (the image's USER), which reads the realm's client secret. +KEYCLOAK_IMAGE_UID=1000 # ---- per-lane state, cleaned up by the trap --------------------------------- PROJECT="" @@ -178,6 +180,15 @@ run_lane() { local client_secret; client_secret="$(random_secret)" GENERATED_SECRETS+=("${client_secret}") (umask 077 && printf '%s' "${client_secret}" >"${secret_file}") + # Compose mounts the file with its owner and mode, and Keycloak reads it as its image user, uid + # 1000. A developer with that uid owns the file already. A CI job runs as root, so the file is + # handed to uid 1000 and stays 0600. Anyone else gets 0644, as the Mailpit key below does: the + # value is random, lives for one run and sits in a Git-ignored directory removed on teardown. + if [[ "$(id -u)" == 0 ]]; then + chown "${KEYCLOAK_IMAGE_UID}:0" "${secret_file}" + elif [[ "$(id -u)" != "${KEYCLOAK_IMAGE_UID}" ]]; then + chmod 0644 "${secret_file}" + fi # A CA and a server certificate for the host name `db`, when the lane brings the TLS overlay. #