We're using IdentityServer3 as Identity provider and one of our claims are Permissions.
But when user has only one permissions, resulting JWT contains property with name "permission" but value is simple string otherwise it's an array. How can we declare claim value "permission" as an array?
Here is snipper how we're filling claims:
foreach (var permission in permissions)
{
claims.Add(new Claim(Scopes.SCOPE_PERMISSION, $"{permission.id}>>{permission.name}"));
}
Identity server comes with value type json
, so "permission" property can be encapsulated as
claims.Add(
new Claim(
Scopes.SCOPE_PERMISSION,
JsonConvert.SerializeObject(permissions.Select(s => $"{s.id}>>{s.name}")),
"json"));