From: Junio C Hamano Date: Thu, 8 Feb 2024 21:20:34 +0000 (-0800) Subject: Merge branch 'mh/credential-oauth-refresh-token-with-wincred' X-Git-Tag: v2.44.0-rc0~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bec916039422e5b67c996e0180148fc5d30b0324;p=thirdparty%2Fgit.git Merge branch 'mh/credential-oauth-refresh-token-with-wincred' The wincred credential backend has been taught to support oauth refresh token the same way as credential-cache and credential-libsecret backends. * mh/credential-oauth-refresh-token-with-wincred: credential/wincred: store oauth_refresh_token --- bec916039422e5b67c996e0180148fc5d30b0324 diff --cc contrib/credential/wincred/git-credential-wincred.c index 4cd56c42e2,f8968ec864..4be0d58cd8 --- a/contrib/credential/wincred/git-credential-wincred.c +++ b/contrib/credential/wincred/git-credential-wincred.c @@@ -146,12 -139,27 +151,27 @@@ static void get_credential(void /* search for the first credential that matches username */ for (i = 0; i < num_creds; ++i) - if (match_cred(creds[i])) { + if (match_cred(creds[i], 0)) { write_item("username", creds[i]->UserName, creds[i]->UserName ? wcslen(creds[i]->UserName) : 0); - write_item("password", - (LPCWSTR)creds[i]->CredentialBlob, - creds[i]->CredentialBlobSize / sizeof(WCHAR)); + if (creds[i]->CredentialBlobSize > 0) { + secret = xmalloc(creds[i]->CredentialBlobSize); + wcsncpy_s(secret, creds[i]->CredentialBlobSize, (LPCWSTR)creds[i]->CredentialBlob, creds[i]->CredentialBlobSize / sizeof(WCHAR)); + line = wcstok_s(secret, L"\r\n", &remaining_lines); + write_item("password", line, line ? wcslen(line) : 0); + while(line != NULL) { + part = wcstok_s(line, L"=", &remaining_parts); + if (!wcscmp(part, L"oauth_refresh_token")) { + write_item("oauth_refresh_token", remaining_parts, remaining_parts ? wcslen(remaining_parts) : 0); + } + line = wcstok_s(NULL, L"\r\n", &remaining_lines); + } + free(secret); + } else { + write_item("password", + (LPCWSTR)creds[i]->CredentialBlob, + creds[i]->CredentialBlobSize / sizeof(WCHAR)); + } for (int j = 0; j < creds[i]->AttributeCount; j++) { attr = creds[i]->Attributes + j; if (!wcscmp(attr->Keyword, L"git_password_expiry_utc")) {