From 98da74cbbdef749478bb3747c633823bcdad4925 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Tue, 5 Nov 2024 11:43:29 +0100 Subject: [PATCH] Fixes #25804: Use the system token header file in agent scripts --- share/commands/server-reload-groups | 2 +- share/commands/server-reload-techniques | 2 +- share/lib/api_call.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/commands/server-reload-groups b/share/commands/server-reload-groups index e2c1ea3..c5ffb16 100755 --- a/share/commands/server-reload-groups +++ b/share/commands/server-reload-groups @@ -26,7 +26,7 @@ while getopts "iIvdc" opt; do done action="reload groups" -curl_opt="--header \"X-API-Token: ${TOKEN}\" --request POST" +curl_opt="--header @/var/rudder/run/api-token-header --request POST" expected='{"action":"reloadGroups","result":"success","data":{"groups":"Started"}}' checked_api_call "http://127.0.0.1:8080/rudder/api/latest/system/reload/groups" "reload groups" "${DISPLAY_COMMAND}" "${expected}" "${curl_opt}" diff --git a/share/commands/server-reload-techniques b/share/commands/server-reload-techniques index 5924a76..faaa4f1 100755 --- a/share/commands/server-reload-techniques +++ b/share/commands/server-reload-techniques @@ -27,7 +27,7 @@ done # Make call to jetty directly and bypass apache conf so we are sure we have no problem to call reload techniques API action="reload techniques from files" -curl_opt="--header \"X-API-Token: ${TOKEN}\" --request POST" +curl_opt="--header @/var/rudder/run/api-token-header --request POST" expected='{"action":"reloadTechniques","result":"success","data":{"techniques":"Started"}}' checked_api_call "http://127.0.0.1:8080/rudder/api/latest/system/reload/techniques" "reload techniques from files" "${DISPLAY_COMMAND}" "${expected}" "${curl_opt}" diff --git a/share/lib/api_call.sh b/share/lib/api_call.sh index e44c14d..152d02a 100644 --- a/share/lib/api_call.sh +++ b/share/lib/api_call.sh @@ -42,7 +42,7 @@ rudder_api_call() { action="$2" curl_opt="$3" display_command="$4" - curl_command="${DOWNLOAD_COMMAND} --header \"X-API-Token: ${TOKEN}\" --header \"Content-Type: application/json\" --request ${action} \"${API_URL}/api/latest${api}\" ${curl_opt}" + curl_command="${DOWNLOAD_COMMAND} --header @/var/rudder/run/api-token-header --header \"Content-Type: application/json\" --request ${action} \"${API_URL}/api/latest${api}\" ${curl_opt}" if ${display_command}; then printf "${WHITE}${curl_command}${NORMAL}\n\n" >&2