Skip to content

Commit 058d3ab

Browse files
committed
Fix password based authentication for LFS
1 parent 7a43762 commit 058d3ab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

p4-fusion/lfs/communication/lfscomm.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ BatchResponse PerformBatchUploadRequest(const std::string& serverUrl, const Cred
369369
return result;
370370
}
371371

372-
Communicator::UploadResult PerformUpload(const std::string& uploadUrl, const std::vector<char>& fileContents, const std::map<std::string, std::string>& actionHeaders)
372+
Communicator::UploadResult PerformUpload(const std::string& uploadUrl, const std::vector<char>& fileContents, const std::map<std::string, std::string>& actionHeaders, const Credentials& auth = Credentials())
373373
{
374374
// Initialize curl
375375
CURLHandle curl;
@@ -394,7 +394,7 @@ Communicator::UploadResult PerformUpload(const std::string& uploadUrl, const std
394394
uploadHeaders = CreateHeadersFromMap(actionHeaders, uploadHeaders);
395395

396396
RequestResult uploadResult = {};
397-
SetupRequest(curl.get(), uploadUrl, fileContents.data(), fileContents.size(), uploadHeaders, &uploadResult);
397+
SetupRequest(curl.get(), uploadUrl, fileContents.data(), fileContents.size(), uploadHeaders, &uploadResult, auth);
398398
curl_easy_setopt(curl.get(), CURLOPT_CUSTOMREQUEST, "PUT");
399399

400400
uploadResult = PerformRequestWithRetry([&]() -> RequestResult
@@ -436,7 +436,7 @@ std::string CreateVerifyPayload(const std::string& oid, size_t fileSize)
436436
return verifyBuffer.GetString();
437437
}
438438

439-
bool PerformVerify(const std::string& verifyUrl, const std::string& oid, size_t fileSize, const std::map<std::string, std::string>& actionHeaders)
439+
bool PerformVerify(const std::string& verifyUrl, const std::string& oid, size_t fileSize, const std::map<std::string, std::string>& actionHeaders, const Credentials& auth = Credentials())
440440
{
441441
CURLHandle curl;
442442
if (!curl)
@@ -453,7 +453,7 @@ bool PerformVerify(const std::string& verifyUrl, const std::string& oid, size_t
453453

454454
// Perform request without authentication (headers from action should contain auth)
455455
RequestResult verifyResult = {};
456-
SetupRequest(curl.get(), verifyUrl, verifyPayload.data(), verifyPayload.size(), verifyHeaders, &verifyResult);
456+
SetupRequest(curl.get(), verifyUrl, verifyPayload.data(), verifyPayload.size(), verifyHeaders, &verifyResult, auth);
457457

458458
verifyResult = PerformRequestWithRetry([&]() -> RequestResult
459459
{
@@ -492,15 +492,15 @@ Communicator::UploadResult LFSComm::UploadFile(const std::vector<char>& fileCont
492492
return UploadResult::AlreadyExists;
493493
}
494494

495-
auto uploadResult = PerformUpload(batchResponse.uploadUrl, fileContents, batchResponse.uploadHeaders);
495+
auto uploadResult = PerformUpload(batchResponse.uploadUrl, fileContents, batchResponse.uploadHeaders, m_Creds);
496496
if (uploadResult != UploadResult::Uploaded)
497497
{
498498
return uploadResult;
499499
}
500500

501501
if (!batchResponse.verifyUrl.empty())
502502
{
503-
if (!PerformVerify(batchResponse.verifyUrl, oid, fileContents.size(), batchResponse.verifyHeaders))
503+
if (!PerformVerify(batchResponse.verifyUrl, oid, fileContents.size(), batchResponse.verifyHeaders, m_Creds))
504504
{
505505
return UploadResult::Error;
506506
}

0 commit comments

Comments
 (0)