Skip to content

Commit 4ae96a4

Browse files
committed
Merge branch 'ap/http-probe-rpc-use-auth'
HTTP transport failed to authenticate in some code paths, which has been corrected. * ap/http-probe-rpc-use-auth: remote-curl: use auth for probe_rpc() requests too
2 parents c3a5261 + ed0f7a6 commit 4ae96a4

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

remote-curl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
876876

877877
headers = curl_slist_append(headers, rpc->hdr_content_type);
878878
headers = curl_slist_append(headers, rpc->hdr_accept);
879+
headers = http_append_auth_header(&http_auth, headers);
879880

880881
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);
881882
curl_easy_setopt(slot->curl, CURLOPT_POST, 1L);

t/t5563-simple-http-auth.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,51 @@ test_expect_success 'access using bearer auth with invalid credentials' '
605605
EOF
606606
'
607607

608+
test_expect_success 'clone with bearer auth and probe_rpc' '
609+
test_when_finished "per_test_cleanup" &&
610+
test_when_finished "rm -rf large.git" &&
611+
612+
# Set up a repository large enough to trigger probe_rpc
613+
git init large.git &&
614+
(
615+
cd large.git &&
616+
git config set maintenance.auto false &&
617+
git commit --allow-empty --message "initial" &&
618+
# Create many refs to trigger probe_rpc, which is called when
619+
# the request body is larger than http.postBuffer.
620+
#
621+
# In the test later, http.postBuffer is set to 70000. Each
622+
# "want" line is ~45 bytes, so we need at least 70000/45 = ~1600
623+
# refs
624+
test_seq -f "create refs/heads/branch-%d @" 2000 |
625+
git update-ref --stdin
626+
) &&
627+
git clone --bare large.git "$HTTPD_DOCUMENT_ROOT_PATH/large.git" &&
628+
629+
# Clone it through HTTP with a Bearer token
630+
set_credential_reply get <<-EOF &&
631+
capability[]=authtype
632+
authtype=Bearer
633+
credential=YS1naXQtdG9rZW4=
634+
EOF
635+
636+
# Bearer token
637+
cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
638+
id=1 creds=Bearer YS1naXQtdG9rZW4=
639+
EOF
640+
641+
cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
642+
id=1 status=200
643+
id=default response=WWW-Authenticate: Bearer authorize_uri="id.example.com"
644+
EOF
645+
646+
# Set a small buffer to force probe_rpc to be called
647+
# Must be > LARGE_PACKET_MAX (65520)
648+
test_config_global http.postBuffer 70000 &&
649+
test_config_global credential.helper test-helper &&
650+
git clone "$HTTPD_URL/custom_auth/large.git" partial-auth-clone 2>clone-error
651+
'
652+
608653
test_expect_success 'access using three-legged auth' '
609654
test_when_finished "per_test_cleanup" &&
610655

0 commit comments

Comments
 (0)