Skip to content

Commit

Permalink
Correct Aviso Auth token format
Browse files Browse the repository at this point in the history
Re ECFLOW-1982
  • Loading branch information
marcosbento committed Oct 25, 2024
1 parent 37c6818 commit 477bfeb
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
4 changes: 3 additions & 1 deletion libs/node/src/ecflow/node/AvisoAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 8 additions & 2 deletions libs/rest/src/ecflow/http/HttpLibrary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
#define CPPHTTPLIB_RECV_FLAGS MSG_NOSIGNAL
#endif

#ifdef ECF_OPENSSL
#define CPPHTTPLIB_OPENSSL_SUPPORT
#if defined(ECF_OPENSSL)
#include <openssl/ssl.h>
#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
Expand Down
4 changes: 3 additions & 1 deletion libs/service/src/ecflow/service/auth/Credentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ std::optional<Credentials::UserCredentials> Credentials::user() const {

std::optional<Credentials::KeyCredentials> 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;
}
Expand Down
1 change: 1 addition & 0 deletions libs/service/src/ecflow/service/auth/Credentials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Credentials {

struct KeyCredentials
{
std::string email;
std::string key;
};

Expand Down
9 changes: 9 additions & 0 deletions libs/service/src/ecflow/service/aviso/Aviso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

#include "ecflow/service/aviso/Aviso.hpp"

#if defined(ECF_OPENSSL)
#include <openssl/ssl.h>
#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 <cassert>
#include <fstream>
#include <httplib.h>
Expand Down
4 changes: 3 additions & 1 deletion libs/service/src/ecflow/service/aviso/AvisoService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() << "}");
Expand Down
2 changes: 1 addition & 1 deletion libs/service/src/ecflow/service/aviso/etcd/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ std::vector<std::pair<std::string, std::string>> 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);
Expand Down

0 comments on commit 477bfeb

Please sign in to comment.