Don't use VstsCredProvider if build task env vars are set (#56)
This commit is contained in:
Родитель
bffa42f955
Коммит
a7de23f53e
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CredentialProviderVersion>0.1.10</CredentialProviderVersion>
|
||||
<CredentialProviderVersion>0.1.11</CredentialProviderVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -37,6 +37,18 @@ namespace NuGetCredentialProvider.CredentialProviders.Vsts
|
|||
|
||||
public override async Task<bool> CanProvideCredentialsAsync(Uri uri)
|
||||
{
|
||||
// If for any reason we reach this point and any of the three build task env vars are set,
|
||||
// we should not try get credentials with this cred provider.
|
||||
string feedEndPointsJsonEnvVar = Environment.GetEnvironmentVariable(EnvUtil.BuildTaskExternalEndpoints);
|
||||
string uriPrefixesStringEnvVar = Environment.GetEnvironmentVariable(EnvUtil.BuildTaskUriPrefixes);
|
||||
string accessTokenEnvVar = Environment.GetEnvironmentVariable(EnvUtil.BuildTaskAccessToken);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(feedEndPointsJsonEnvVar) == false || string.IsNullOrWhiteSpace(uriPrefixesStringEnvVar) == false || string.IsNullOrWhiteSpace(accessTokenEnvVar) == false)
|
||||
{
|
||||
Verbose(Resources.BuildTaskCredProviderIsUsedError);
|
||||
return false;
|
||||
}
|
||||
|
||||
var validHosts = EnvUtil.GetHostsFromEnvironment(Logger, EnvUtil.SupportedHostsEnvVar, new[]
|
||||
{
|
||||
".pkgs.vsts.me", // DevFabric
|
||||
|
|
|
@ -68,6 +68,8 @@ namespace NuGetCredentialProvider.RequestHandlers
|
|||
var cancelMessage = MessageUtilities.Create(message.RequestId, MessageType.Cancel, message.Method);
|
||||
await connection.SendAsync(cancelMessage, CancellationToken.None);
|
||||
|
||||
Logger.Verbose(ex.ToString());
|
||||
|
||||
// We must guarantee that exactly one terminating message is sent, so do not fall through to send
|
||||
// the normal response, but also do not rethrow.
|
||||
return;
|
||||
|
@ -89,7 +91,7 @@ namespace NuGetCredentialProvider.RequestHandlers
|
|||
}
|
||||
|
||||
Logger.Verbose(string.Format(Resources.ResponseHandlerException, message.Method, message.RequestId));
|
||||
Logger.Error(ex.ToString());
|
||||
Logger.Verbose(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче