[fdbbackup] check for credentials inside of setAuthHeaders

This commit is contained in:
Kevin King 2020-10-08 15:47:49 -07:00 committed by sfc-gh-tclinkenbeard
parent 4059b1f570
commit b10ea7677e
2 changed files with 9 additions and 5 deletions

View File

@ -661,9 +661,8 @@ ACTOR Future<Reference<HTTP::Response>> doRequest_impl(Reference<S3BlobStoreEndp
// Finish/update the request headers (which includes Date header)
// This must be done AFTER the connection is ready because if credentials are coming from disk they are
// refreshed when a new connection is established and setAuthHeaders() would need the updated secret.
if (bstore->credentials.present()) {
bstore->setAuthHeaders(bstore->credentials.get(), verb, resource, headers);
}
bstore->setAuthHeaders(verb, resource, headers);
remoteAddress = rconn.conn->getPeerAddress();
wait(bstore->requestRate->getAllowance(1));
Reference<HTTP::Response> _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];

View File

@ -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,