Skip to content

Commit 64204ed

Browse files
committed
Cleanup.
1 parent 510f7c0 commit 64204ed

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs

+8-15
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,19 @@ private static bool TryParseAuthenticationInfo(HttpResponseMessage msg, [NotNull
7171
if (header.Scheme is not null)
7272
{
7373
scheme = header.Scheme;
74-
var keyValues = ParseBearerArgs(header.Parameter);
75-
if (keyValues is null)
76-
{
77-
return false;
78-
}
7974

8075
if (header.Scheme.Equals(BasicAuthScheme, StringComparison.OrdinalIgnoreCase))
8176
{
82-
return TryParseBasicAuthInfo(keyValues, msg.RequestMessage!.RequestUri!, out bearerAuthInfo);
77+
bearerAuthInfo = null;
78+
return true;
8379
}
8480
else if (header.Scheme.Equals(BearerAuthScheme, StringComparison.OrdinalIgnoreCase))
8581
{
82+
var keyValues = ParseBearerArgs(header.Parameter);
83+
if (keyValues is null)
84+
{
85+
return false;
86+
}
8687
return TryParseBearerAuthInfo(keyValues, out bearerAuthInfo);
8788
}
8889
else
@@ -110,12 +111,6 @@ static bool TryParseBearerAuthInfo(Dictionary<string, string> authValues, [NotNu
110111
}
111112
}
112113

113-
static bool TryParseBasicAuthInfo(Dictionary<string, string> authValues, Uri requestUri, out AuthInfo? authInfo)
114-
{
115-
authInfo = null;
116-
return true;
117-
}
118-
119114
static Dictionary<string, string>? ParseBearerArgs(string? bearerHeaderArgs)
120115
{
121116
if (bearerHeaderArgs is null)
@@ -159,7 +154,6 @@ public DateTimeOffset ResolvedExpiration
159154
/// </summary>
160155
private async Task<(AuthenticationHeaderValue, DateTimeOffset)?> GetAuthenticationAsync(string registry, string scheme, AuthInfo? bearerAuthInfo, CancellationToken cancellationToken)
161156
{
162-
163157
DockerCredentials? privateRepoCreds;
164158
// Allow overrides for auth via environment variables
165159
if (GetDockerCredentialsFromEnvironment(_registryMode) is (string credU, string credP))
@@ -311,8 +305,7 @@ internal static (string credU, string credP)? GetDockerCredentialsFromEnvironmen
311305
else
312306
{
313307
_logger.LogTrace(Resource.GetString(nameof(Strings.CouldntDeserializeJsonToken)));
314-
// logging and returning null to try HTTP GET instead
315-
return null;
308+
return null; // try next method
316309
}
317310
}
318311

0 commit comments

Comments
 (0)