From 477bfeb915811f3ef26d34249810756c75826b92 Mon Sep 17 00:00:00 2001 From: Marcos Bento Date: Fri, 25 Oct 2024 11:47:45 +0000 Subject: [PATCH] Correct Aviso Auth token format Re ECFLOW-1982 --- libs/node/src/ecflow/node/AvisoAttr.cpp | 4 +++- libs/rest/src/ecflow/http/HttpLibrary.hpp | 10 ++++++++-- libs/service/src/ecflow/service/auth/Credentials.cpp | 4 +++- libs/service/src/ecflow/service/auth/Credentials.hpp | 1 + libs/service/src/ecflow/service/aviso/Aviso.cpp | 9 +++++++++ libs/service/src/ecflow/service/aviso/AvisoService.cpp | 4 +++- libs/service/src/ecflow/service/aviso/etcd/Client.cpp | 2 +- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/libs/node/src/ecflow/node/AvisoAttr.cpp b/libs/node/src/ecflow/node/AvisoAttr.cpp index 31b66f7b2..e392e9969 100644 --- a/libs/node/src/ecflow/node/AvisoAttr.cpp +++ b/libs/node/src/ecflow/node/AvisoAttr.cpp @@ -94,7 +94,6 @@ void AvisoAttr::reset() { } bool AvisoAttr::isFree() const { - SLOG(D, "AvisoAttr: check Aviso attribute (name: " << name_ << ", listener: " << listener_ << ") is free"); if (controller_ == nullptr) { return false; @@ -105,6 +104,7 @@ bool AvisoAttr::isFree() const { if (notifications.empty()) { // No notifications, nothing to do -- task continues to wait + SLOG(D, "AvisoAttr: (path: " << this->path() << ", name: " << name_ << ", listener: " << listener_ << "): no notifications found"); return false; } @@ -143,6 +143,8 @@ bool AvisoAttr::isFree() const { ecf::visit_parents(*parent_, [n = this->state_change_no_](Node& node) { node.set_state_change_no(n); }); + SLOG(D, "AvisoAttr: (path: " << this->path() << ", name: " << name_ << ", listener: " << listener_ << ") " << std::string{(is_free ? "" : "no ")} + "notifications found"); + return is_free; } diff --git a/libs/rest/src/ecflow/http/HttpLibrary.hpp b/libs/rest/src/ecflow/http/HttpLibrary.hpp index 0afdacee9..8ee15690a 100644 --- a/libs/rest/src/ecflow/http/HttpLibrary.hpp +++ b/libs/rest/src/ecflow/http/HttpLibrary.hpp @@ -23,9 +23,15 @@ #define CPPHTTPLIB_RECV_FLAGS MSG_NOSIGNAL #endif -#ifdef ECF_OPENSSL - #define CPPHTTPLIB_OPENSSL_SUPPORT +#if defined(ECF_OPENSSL) + #include + #if OPENSSL_VERSION_NUMBER < 0x1010100fL + #warning OpenSSL versions prior to 1.1.1 detected. Aviso ETCD HTTP client will be build without OpenSSL support! + #else + #define CPPHTTPLIB_OPENSSL_SUPPORT + #endif #endif + #ifdef ECF_HTTP_COMPRESSION #define CPPHTTPLIB_ZLIB_SUPPORT #endif diff --git a/libs/service/src/ecflow/service/auth/Credentials.cpp b/libs/service/src/ecflow/service/auth/Credentials.cpp index e1825b20b..20e0b442a 100644 --- a/libs/service/src/ecflow/service/auth/Credentials.cpp +++ b/libs/service/src/ecflow/service/auth/Credentials.cpp @@ -42,7 +42,9 @@ std::optional Credentials::user() const { std::optional Credentials::key() const { if (auto key = value("key"); key) { - return KeyCredentials{std::move(*key)}; + if (auto email = value("email"); email) { + return KeyCredentials{std::move(*email), std::move(*key)}; + } } return std::nullopt; } diff --git a/libs/service/src/ecflow/service/auth/Credentials.hpp b/libs/service/src/ecflow/service/auth/Credentials.hpp index bcb2132a2..a9fae62a5 100644 --- a/libs/service/src/ecflow/service/auth/Credentials.hpp +++ b/libs/service/src/ecflow/service/auth/Credentials.hpp @@ -27,6 +27,7 @@ class Credentials { struct KeyCredentials { + std::string email; std::string key; }; diff --git a/libs/service/src/ecflow/service/aviso/Aviso.cpp b/libs/service/src/ecflow/service/aviso/Aviso.cpp index c0f487b1e..30c1b5d19 100644 --- a/libs/service/src/ecflow/service/aviso/Aviso.cpp +++ b/libs/service/src/ecflow/service/aviso/Aviso.cpp @@ -10,6 +10,15 @@ #include "ecflow/service/aviso/Aviso.hpp" +#if defined(ECF_OPENSSL) + #include + #if OPENSSL_VERSION_NUMBER < 0x1010100fL + #warning OpenSSL versions prior to 1.1.1 detected. Aviso ETCD HTTP client will be build without OpenSSL support! + #else + #define CPPHTTPLIB_OPENSSL_SUPPORT + #endif +#endif + #include #include #include diff --git a/libs/service/src/ecflow/service/aviso/AvisoService.cpp b/libs/service/src/ecflow/service/aviso/AvisoService.cpp index d6849504d..ad7099d3e 100644 --- a/libs/service/src/ecflow/service/aviso/AvisoService.cpp +++ b/libs/service/src/ecflow/service/aviso/AvisoService.cpp @@ -129,7 +129,9 @@ void AvisoService::register_listener(const AvisoSubscribe& listen) { if (auto auth = listen.auth(); !auth.empty()) { auto credentials = ecf::service::auth::Credentials::load(auth); if (auto key_credentials = credentials.key(); key_credentials) { - inserted.auth_token = key_credentials->key; + auto email = key_credentials->email; + auto key = key_credentials->key; + inserted.auth_token = email + ":" + key; } else { SLOG(I, "AvisoService: no key found in auth token for listener {" << listener.path() << "}"); diff --git a/libs/service/src/ecflow/service/aviso/etcd/Client.cpp b/libs/service/src/ecflow/service/aviso/etcd/Client.cpp index 130795aba..c054a4008 100644 --- a/libs/service/src/ecflow/service/aviso/etcd/Client.cpp +++ b/libs/service/src/ecflow/service/aviso/etcd/Client.cpp @@ -42,7 +42,7 @@ std::vector> Client::poll(std::string_view k if (!auth_token_.empty()) { SLOG(D, "EtcdClient: using authorization token"); - headers.emplace("Authorization", "Bearer " + auth_token_); + headers.emplace("Authorization", "EmailKey " + auth_token_); } auto range = Range(key_prefix);