Skip to content

Commit 07270d0

Browse files
hickfordgitster
authored andcommitted
credential-cache: respect request capabilities
Previously, credential-cache populated authtype regardless of request. Signed-off-by: M Hickford <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f71522 commit 07270d0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

builtin/credential-cache--daemon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ static void serve_one_client(FILE *in, FILE *out)
141141
fprintf(out, "username=%s\n", e->item.username);
142142
if (e->item.password)
143143
fprintf(out, "password=%s\n", e->item.password);
144-
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_HELPER) && e->item.authtype)
144+
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_RESPONSE) && e->item.authtype)
145145
fprintf(out, "authtype=%s\n", e->item.authtype);
146-
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_HELPER) && e->item.credential)
146+
if (credential_has_capability(&c.capa_authtype, CREDENTIAL_OP_RESPONSE) && e->item.credential)
147147
fprintf(out, "credential=%s\n", e->item.credential);
148148
if (e->item.password_expiry_utc != TIME_MAX)
149149
fprintf(out, "password_expiry_utc=%"PRItime"\n",

t/lib-credential.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,21 @@ helper_test_authtype() {
566566
EOF
567567
'
568568

569+
test_expect_success "helper ($HELPER) gets authtype and credential only if request has authtype capability" '
570+
check fill $HELPER <<-\EOF
571+
protocol=https
572+
host=git.example.com
573+
--
574+
protocol=https
575+
host=git.example.com
576+
username=askpass-username
577+
password=askpass-password
578+
--
579+
askpass: Username for '\''https://git.example.com'\'':
580+
askpass: Password for '\''https://[email protected]'\'':
581+
EOF
582+
'
583+
569584
test_expect_success "helper ($HELPER) stores authtype and credential with username" '
570585
check approve $HELPER <<-\EOF
571586
capability[]=authtype

0 commit comments

Comments
 (0)