in src/Microsoft.Azure.SignalR.Common/Auth/JwtPayload.cs [87:123]
public void AddClaims(IEnumerable<Claim> claims)
{
if (claims == null)
{
throw LogHelper.LogExceptionMessage(new ArgumentNullException(nameof(claims)));
}
foreach (var claim in claims)
{
if (claim == null)
{
continue;
}
var jsonClaimType = claim.Type;
var jsonClaimValue = claim.ValueType.Equals(ClaimValueTypes.String, StringComparison.Ordinal) ? claim.Value : TokenUtilities.GetClaimValueUsingValueType(claim);
// If there is an existing value, append to it.
// What to do if the 'ClaimValueType' is not the same.
if (TryGetValue(jsonClaimType, out var existingValue))
{
var claimValues = existingValue as IList<object>;
if (claimValues == null)
{
claimValues = new List<object>();
claimValues.Add(existingValue);
this[jsonClaimType] = claimValues;
}
claimValues.Add(jsonClaimValue);
}
else
{
this[jsonClaimType] = jsonClaimValue;
}
}
}