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 Jul 26, 2023
1 parent 4847c50 commit 9dad6c2
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 9dad6c2

Please sign in to comment.