From b10ea7677e92cfeead4993d22582e223e5e17a9c Mon Sep 17 00:00:00 2001 From: Kevin King <4kevinking@gmail.com> Date: Thu, 8 Oct 2020 15:47:49 -0700 Subject: [PATCH] [fdbbackup] check for credentials inside of setAuthHeaders --- fdbclient/S3BlobStore.actor.cpp | 12 ++++++++---- fdbclient/S3BlobStore.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fdbclient/S3BlobStore.actor.cpp b/fdbclient/S3BlobStore.actor.cpp index 4a9c375be6..33e50f9120 100644 --- a/fdbclient/S3BlobStore.actor.cpp +++ b/fdbclient/S3BlobStore.actor.cpp @@ -661,9 +661,8 @@ ACTOR Future> doRequest_impl(Referencecredentials.present()) { - bstore->setAuthHeaders(bstore->credentials.get(), verb, resource, headers); - } + bstore->setAuthHeaders(verb, resource, headers); + remoteAddress = rconn.conn->getPeerAddress(); wait(bstore->requestRate->getAllowance(1)); Reference _r = wait(timeoutError(HTTP::doRequest(rconn.conn, @@ -1086,7 +1085,12 @@ std::string S3BlobStoreEndpoint::hmac_sha1(Credentials const &creds, std::string return SHA1::from_string(kopad); } -void S3BlobStoreEndpoint::setAuthHeaders(Credentials const &creds, std::string const& verb, std::string const& resource, HTTP::Headers& headers) { +void S3BlobStoreEndpoint::setAuthHeaders(std::string const& verb, std::string const& resource, HTTP::Headers& headers) { + if (!credentials.present()) { + return; + } + Credentials creds = credentials.get(); + std::string& date = headers["Date"]; char dateBuf[20]; diff --git a/fdbclient/S3BlobStore.h b/fdbclient/S3BlobStore.h index bc64deb028..f948ecd359 100644 --- a/fdbclient/S3BlobStore.h +++ b/fdbclient/S3BlobStore.h @@ -166,7 +166,7 @@ public: static std::string hmac_sha1(Credentials const &creds, std::string const &msg); // Sets headers needed for Authorization (including Date which will be overwritten if present) - void setAuthHeaders(Credentials const &creds, std::string const &verb, std::string const &resource, HTTP::Headers &headers); + void setAuthHeaders(std::string const& verb, std::string const& resource, HTTP::Headers& headers); // Prepend the HTTP request header to the given PacketBuffer, returning the new head of the buffer chain static PacketBuffer* writeRequestHeader(std::string const& request,