#!/usr/bin/bash set -euxo pipefail export IRONIC_REVERSE_PROXY_SETUP=${IRONIC_REVERSE_PROXY_SETUP:-false} # CUSTOM_CONFIG_DIR is also managed in the ironic-common.sh, in order to # keep auth-common and ironic-common separate (to stay consistent with the # architecture) part of the ironic-common logic had to be duplicated CUSTOM_CONFIG_DIR="${CUSTOM_CONFIG_DIR:-/conf}" IRONIC_CONF_DIR="${CUSTOM_CONFIG_DIR}/ironic" # Backward compatibility if [[ "${IRONIC_DEPLOYMENT:-}" == "Conductor" ]]; then export IRONIC_EXPOSE_JSON_RPC=true else export IRONIC_EXPOSE_JSON_RPC="${IRONIC_EXPOSE_JSON_RPC:-false}" fi IRONIC_HTPASSWD_FILE="${IRONIC_CONF_DIR}/htpasswd" export IRONIC_RPC_HTPASSWD_FILE="${IRONIC_HTPASSWD_FILE}-rpc" if [[ -f "/auth/ironic/htpasswd" ]]; then IRONIC_HTPASSWD=$( "${IRONIC_RPC_HTPASSWD_FILE}" fi } configure_ironic_auth() { # Configure HTTP basic auth for API server if [[ -n "${IRONIC_HTPASSWD}" ]]; then printf "%s\n" "${IRONIC_HTPASSWD}" > "${IRONIC_HTPASSWD_FILE}" if [[ "${IRONIC_REVERSE_PROXY_SETUP}" == "false" ]]; then crudini --set "${IRONIC_CONFIG}" DEFAULT auth_strategy http_basic crudini --set "${IRONIC_CONFIG}" DEFAULT http_basic_auth_user_file "${IRONIC_HTPASSWD_FILE}" fi fi } write_htpasswd_files() { if [[ -n "${IRONIC_HTPASSWD:-}" ]]; then printf "%s\n" "${IRONIC_HTPASSWD}" > "${IRONIC_HTPASSWD_FILE}" fi }