diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index ace276b..6e333b8 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -580,12 +580,18 @@ dex_public_url() { } dex_bcrypt_hash() { - local image="$1" - local password="$2" + local password="$1" + local helper_image="${DEX_HTPASSWD_IMAGE:-httpd:2.4-alpine}" local output - output="$(sudo docker run --rm "${image}" hash-password "${password}")" - printf '%s\n' "${output}" | grep -Eo '\$2[aby]\$[0-9]{2}\$[^[:space:]]+' | tail -n 1 + if command -v htpasswd >/dev/null 2>&1; then + output="$(printf '%s\n' "${password}" | htpasswd -BinC 10 dex)" + else + sudo docker pull "${helper_image}" >/dev/null + output="$(printf '%s\n' "${password}" | sudo docker run --rm -i "${helper_image}" htpasswd -BinC 10 dex)" + fi + + printf '%s\n' "${output}" | awk -F: '/^dex:/ { print $2; exit }' } render_dex_config() { @@ -691,9 +697,9 @@ deploy_dex() { repair_local_docker_iptables sudo docker pull "${image}" - dex_user_password_hash="$(dex_bcrypt_hash "${image}" "${DEX_USER_PASSWORD}")" + dex_user_password_hash="$(dex_bcrypt_hash "${DEX_USER_PASSWORD}")" if [[ -z "${dex_user_password_hash}" ]]; then - echo "Could not generate Dex bcrypt password hash." >&2 + echo "Could not generate Dex bcrypt password hash with htpasswd." >&2 exit 1 fi