diff --git a/scripts/auth-common.sh b/scripts/auth-common.sh index 90cea4c5b..fb2295bb5 100644 --- a/scripts/auth-common.sh +++ b/scripts/auth-common.sh @@ -15,32 +15,50 @@ IRONIC_HTPASSWD_FILE=/etc/ironic/htpasswd if [[ -f "/auth/ironic/htpasswd" ]]; then IRONIC_HTPASSWD=$( "${IRONIC_HTPASSWD_FILE}-rpc" + + if [[ -z "${IRONIC_RPC_HTPASSWD}" ]]; then + if [[ -f "${username_file}" ]] && [[ -f "${password_file}" ]]; then + htpasswd -c -i -B "${IRONIC_HTPASSWD_FILE}-rpc" "$(<${username_file})" <"${password_file}" + else + echo "FATAL: enabling JSON RPC requires authentication" + exit 1 + fi + else + printf "%s\n" "${IRONIC_RPC_HTPASSWD}" > "${IRONIC_HTPASSWD_FILE}-rpc" + fi fi } configure_ironic_auth() { - local config=/etc/ironic/ironic.conf # Configure HTTP basic auth for API server if [[ -n "${IRONIC_HTPASSWD}" ]]; then printf "%s\n" "${IRONIC_HTPASSWD}" > "${IRONIC_HTPASSWD_FILE}" diff --git a/scripts/configure-ironic.sh b/scripts/configure-ironic.sh index 3c6dc5afc..3c6333e9c 100755 --- a/scripts/configure-ironic.sh +++ b/scripts/configure-ironic.sh @@ -84,12 +84,10 @@ env | grep "^OS_" || true mkdir -p /shared/html mkdir -p /shared/ironic_prometheus_exporter -configure_json_rpc_auth - # The original ironic.conf is empty, and can be found in ironic.conf_orig render_j2_config /etc/ironic/ironic.conf.j2 /etc/ironic/ironic.conf -configure_client_basic_auth ironic-rpc +configure_json_rpc_auth # Make sure ironic traffic bypasses any proxies export NO_PROXY="${NO_PROXY:-},$IRONIC_IP"