From 809669924334e4b641cbf43460d79ca9a2099066 Mon Sep 17 00:00:00 2001 From: Marcos Bento Date: Wed, 27 Sep 2023 09:41:34 +0100 Subject: [PATCH] ecflow_http: authenticate both user+task requests Re: ECFLOW-1921 --- Http/src/ApiV1Impl.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Http/src/ApiV1Impl.cpp b/Http/src/ApiV1Impl.cpp index 42e5e811e..8fcddbc91 100644 --- a/Http/src/ApiV1Impl.cpp +++ b/Http/src/ApiV1Impl.cpp @@ -232,15 +232,15 @@ std::unique_ptr get_client(const httplib::Request& request) { return ci; } -std::unique_ptr get_client(const ecf::ojson& j) { - auto ci = std::make_unique(); +std::unique_ptr get_client_for_tasks(const httplib::Request& request, const ecf::ojson& payload) { + auto ci = get_client(request); - ci->set_child_path(j.at("ECF_NAME").get()); - ci->set_child_password(j.at("ECF_PASS").get()); - ci->set_child_pid(json_type_to_string(j.at("ECF_RID"))); - ci->set_child_try_no(std::stoi(json_type_to_string(j.at("ECF_TRYNO")))); - ci->set_child_timeout(j.value("ECF_TIMEOUT", 86400)); - ci->set_zombie_child_timeout(j.value("ECF_ZOMBIE_TIMEOUT", 43200)); + ci->set_child_path(payload.at("ECF_NAME").get()); + ci->set_child_password(payload.at("ECF_PASS").get()); + ci->set_child_pid(json_type_to_string(payload.at("ECF_RID"))); + ci->set_child_try_no(std::stoi(json_type_to_string(payload.at("ECF_TRYNO")))); + ci->set_child_timeout(payload.value("ECF_TIMEOUT", 86400)); + ci->set_zombie_child_timeout(payload.value("ECF_ZOMBIE_TIMEOUT", 43200)); return ci; } @@ -805,7 +805,8 @@ ecf::ojson update_node_attribute(const httplib::Request& request) { "Invalid action for child command: " + name); } - auto client = get_client(payload); + auto client = get_client_for_tasks(request, payload); + const std::string value = payload.at("value"); if (type == "event") { @@ -1017,7 +1018,7 @@ ecf::ojson update_node_status(const httplib::Request& request) { "Invalid action for child command: " + name); } - auto client = get_client(payload); + auto client = get_client_for_tasks(request, payload); if (name == "init") { client->child_init();