forked from wazuh/wazuh-docker
Added authorization to every Elastic request
This commit is contained in:
@@ -21,7 +21,7 @@ else
|
|||||||
auth="--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}"
|
auth="--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
until curl -XGET $el_url; do
|
until curl ${auth} -XGET $el_url; do
|
||||||
>&2 echo "Elastic is unavailable - sleeping"
|
>&2 echo "Elastic is unavailable - sleeping"
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
@@ -41,9 +41,9 @@ API_USER_Q=`echo "$API_USER" | tr -d '"'`
|
|||||||
API_PASSWORD=`echo -n $API_PASS_Q | base64`
|
API_PASSWORD=`echo -n $API_PASS_Q | base64`
|
||||||
|
|
||||||
echo "Setting API credentials into Wazuh APP"
|
echo "Setting API credentials into Wazuh APP"
|
||||||
CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/wazuh-configuration/1513629884013)
|
CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/wazuh-configuration/1513629884013 ${auth})
|
||||||
if [ "x$CONFIG_CODE" = "x404" ]; then
|
if [ "x$CONFIG_CODE" = "x404" ]; then
|
||||||
curl -s -XPOST ${auth} $el_url/.wazuh/wazuh-configuration/1513629884013 -H 'Content-Type: application/json' -d'
|
curl -s -XPOST $el_url/.wazuh/wazuh-configuration/1513629884013 ${auth} -H 'Content-Type: application/json' -d'
|
||||||
{
|
{
|
||||||
"api_user": "'"$API_USER_Q"'",
|
"api_user": "'"$API_USER_Q"'",
|
||||||
"api_password": "'"$API_PASSWORD"'",
|
"api_password": "'"$API_PASSWORD"'",
|
||||||
@@ -72,7 +72,7 @@ else
|
|||||||
fi
|
fi
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
curl -XPUT "$el_url/_cluster/settings" -H 'Content-Type: application/json' -d'
|
curl -XPUT "$el_url/_cluster/settings" ${auth} -H 'Content-Type: application/json' -d'
|
||||||
{
|
{
|
||||||
"persistent": {
|
"persistent": {
|
||||||
"xpack.monitoring.collection.enabled": true
|
"xpack.monitoring.collection.enabled": true
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ else
|
|||||||
el_url="${ELASTICSEARCH_URL}"
|
el_url="${ELASTICSEARCH_URL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
until curl -XGET $el_url; do
|
if [ "x${ELASTICSEARCH_USERNAME}" = "x"]; then
|
||||||
|
auth=""
|
||||||
|
else
|
||||||
|
auth="--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
until curl -XGET $el_url ${auth}; do
|
||||||
>&2 echo "Elastic is unavailable - sleeping"
|
>&2 echo "Elastic is unavailable - sleeping"
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user