Added authorization to every Elastic request

This commit is contained in:
manuasir
2019-02-12 17:10:46 +01:00
parent 9a841fdbd3
commit 89e6af0d9a
2 changed files with 11 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ else
auth="--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}"
fi
until curl -XGET $el_url; do
until curl ${auth} -XGET $el_url; do
>&2 echo "Elastic is unavailable - sleeping"
sleep 5
done
@@ -41,9 +41,9 @@ API_USER_Q=`echo "$API_USER" | tr -d '"'`
API_PASSWORD=`echo -n $API_PASS_Q | base64`
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
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_password": "'"$API_PASSWORD"'",
@@ -72,7 +72,7 @@ else
fi
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": {
"xpack.monitoring.collection.enabled": true