From f83a09a0d8203714b7cd2fcaefb3d042f828a7da Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 18 Sep 2024 13:23:25 +0200 Subject: [PATCH] Cleanup. --- .../AuthHandshakeMessageHandler.cs | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs b/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs index e69c8a5ae1ee..46761e94df7c 100644 --- a/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs +++ b/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs @@ -71,18 +71,19 @@ private static bool TryParseAuthenticationInfo(HttpResponseMessage msg, [NotNull if (header.Scheme is not null) { scheme = header.Scheme; - var keyValues = ParseBearerArgs(header.Parameter); - if (keyValues is null) - { - return false; - } if (header.Scheme.Equals(BasicAuthScheme, StringComparison.OrdinalIgnoreCase)) { - return TryParseBasicAuthInfo(keyValues, msg.RequestMessage!.RequestUri!, out bearerAuthInfo); + bearerAuthInfo = null; + return true; } else if (header.Scheme.Equals(BearerAuthScheme, StringComparison.OrdinalIgnoreCase)) { + var keyValues = ParseBearerArgs(header.Parameter); + if (keyValues is null) + { + return false; + } return TryParseBearerAuthInfo(keyValues, out bearerAuthInfo); } else @@ -110,12 +111,6 @@ static bool TryParseBearerAuthInfo(Dictionary authValues, [NotNu } } - static bool TryParseBasicAuthInfo(Dictionary authValues, Uri requestUri, out AuthInfo? authInfo) - { - authInfo = null; - return true; - } - static Dictionary? ParseBearerArgs(string? bearerHeaderArgs) { if (bearerHeaderArgs is null) @@ -159,7 +154,6 @@ public DateTimeOffset ResolvedExpiration /// private async Task<(AuthenticationHeaderValue, DateTimeOffset)?> GetAuthenticationAsync(string registry, string scheme, AuthInfo? bearerAuthInfo, CancellationToken cancellationToken) { - DockerCredentials? privateRepoCreds; // Allow overrides for auth via environment variables if (GetDockerCredentialsFromEnvironment(_registryMode) is (string credU, string credP)) @@ -311,8 +305,7 @@ internal static (string credU, string credP)? GetDockerCredentialsFromEnvironmen else { _logger.LogTrace(Resource.GetString(nameof(Strings.CouldntDeserializeJsonToken))); - // logging and returning null to try HTTP GET instead - return null; + return null; // try next method } }