Skip to content

Commit de4de3c

Browse files
authored
Don't return an empty user message string in OIDC flow (#10663)
1 parent 7355897 commit de4de3c

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/NuGetGallery.Services/Authentication/Federated/FederatedCredentialPolicyEvaluator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public async Task<OidcTokenEvaluationResult> GetMatchingPolicyAsync(
144144
}
145145
}
146146

147-
return OidcTokenEvaluationResult.NoMatchingPolicy(disclosableErrors.ToString());
147+
string? userError = disclosableErrors.Length > 0 ? disclosableErrors.ToString() : null;
148+
return OidcTokenEvaluationResult.NoMatchingPolicy(userError);
148149
}
149150

150151
private async Task ExecuteAdditionalValidatorsAsync(NameValueCollection requestHeaders, TokenContext context)

src/NuGetGallery.Services/Telemetry/QuietLog.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -47,7 +47,7 @@ private static void LogHandledExceptionCore(Exception e, string aggregateExcepti
4747
try
4848
{
4949
// send exception to AppInsights
50-
Telemetry.TrackException(e, new Dictionary<string, string>
50+
Telemetry?.TrackException(e, new Dictionary<string, string>
5151
{
5252
{ "aggregateExceptionId", aggregateExceptionId }
5353
});
@@ -97,4 +97,4 @@ internal static Dictionary<string, string> GetObfuscatedServerVariables(HttpCont
9797
return obfuscatedServerVariables;
9898
}
9999
}
100-
}
100+
}

tests/NuGetGallery.Facts/Authentication/Federated/FederatedCredentialPolicyEvaluatorFacts.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ public async Task ReturnsNoMatchingPolicyWhenNoneAreProvided()
228228

229229
// Assert
230230
Assert.Equal(OidcTokenEvaluationResultType.NoMatchingPolicy, evaluation.Type);
231+
Assert.Null(evaluation.UserError);
231232

232233
AssertNoPoliciesCredentialAudit();
233234
}

0 commit comments

Comments
 (0)