Prevent clashes with git credentials

This commit is contained in:
2025-03-20 23:11:01 +01:00
parent c49f59122c
commit b4a63bf7a8

View File

@@ -7,6 +7,7 @@ namespace NugetSecretCredential;
sealed class GitTokenCredentialProvider : ICredentialProvider
{
private const string TokenUserName = "nugetToken"; // can be anything constant
private const string ProtocolName = "nuget"; // prevent clash with git credentials
private const int MaxCredentialHelperTimeout = 2000;
@@ -44,7 +45,7 @@ sealed class GitTokenCredentialProvider : ICredentialProvider
// Credential helper executable not found
return new GetAuthenticationCredentialsResponse(null, null, null, null, responseCode: MessageResponseCode.Error);
pHelper.StandardInput.WriteLine("protocol=https");
pHelper.StandardInput.WriteLine("protocol=" + ProtocolName);
pHelper.StandardInput.WriteLine("username=" + TokenUserName);
pHelper.StandardInput.WriteLine("host=" + request.Uri.DnsSafeHost);
pHelper.StandardInput.WriteLine();
@@ -89,7 +90,7 @@ sealed class GitTokenCredentialProvider : ICredentialProvider
// Credential helper executable not found
return new GetAuthenticationCredentialsResponse(null, null, null, null, responseCode: MessageResponseCode.Error);
pHelperStore.StandardInput.WriteLine("protocol=https");
pHelperStore.StandardInput.WriteLine("protocol=" + ProtocolName);
pHelperStore.StandardInput.WriteLine("username=" + TokenUserName);
pHelperStore.StandardInput.WriteLine("password=" + password);
pHelperStore.StandardInput.WriteLine("host=" + request.Uri.DnsSafeHost);