Skip to content

Commit

Permalink
Fix erroneous double list allocation in JsonWebToken.Audiences (#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored and Brent Schmaltz committed Jul 28, 2023
1 parent 98016a3 commit a4f4eaf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,10 @@ public IEnumerable<string> Audiences
if (Payload.TryGetValue(JwtRegisteredClaimNames.Aud, out JsonElement audiences))
{
if (audiences.ValueKind == JsonValueKind.String)
_audiences = new List<string> { audiences.GetString() };

if (audiences.ValueKind == JsonValueKind.Array)
{
_audiences.Add(audiences.GetString());
}
else if (audiences.ValueKind == JsonValueKind.Array)
{
foreach (JsonElement jsonElement in audiences.EnumerateArray())
_audiences.Add(jsonElement.ToString());
Expand Down

0 comments on commit a4f4eaf

Please sign in to comment.