Skip to content

Commit

Permalink
GetPayloadClaim<object>("aud") will return a single string when aud i…
Browse files Browse the repository at this point in the history
…s a simple string.
  • Loading branch information
Brent Schmaltz authored and brentschmaltz committed Sep 27, 2023
1 parent ba30608 commit cb46565
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ internal JsonClaimSet CreatePayloadClaimSet(byte[] bytes, int length)
else
{
if (reader.TokenType != JsonTokenType.Null)
{
_audiences.Add(JsonSerializerPrimitives.ReadString(ref reader, JwtRegisteredClaimNames.Aud, ClassName));

claims[JwtRegisteredClaimNames.Aud] = _audiences;
claims[JwtRegisteredClaimNames.Aud] = _audiences[0];
}
else
{
claims[JwtRegisteredClaimNames.Aud] = _audiences;
}
}
}
else if (reader.ValueTextEquals(JwtPayloadUtf8Bytes.Azp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ public static TheoryData<GetPayloadValueTheoryData> CheckAudienceValuesTheoryDat
{
var theoryData = new TheoryData<GetPayloadValueTheoryData>();

theoryData.Add(new GetPayloadValueTheoryData("stringFromSingleAsObject")
{
ClaimValue = "audience",
PropertyName = "aud",
PropertyType = typeof(object),
PropertyValue = new List<string> { "audience" },
Json = JsonUtilities.CreateUnsignedToken("aud", "audience")
});

theoryData.Add(new GetPayloadValueTheoryData("stringFromSingleInList")
{
ClaimValue = "audience",
Expand Down

0 comments on commit cb46565

Please sign in to comment.