Open
Description
Summary
Support creating custom claims as an array type using the user-jwts
tool.
Motivation and goals
- It is a common use case for JWTs to contain custom claims that are an array type. For example:
{
"fooIds": [
"427ba6fa-7e92-49ff-b180-944cf0c9e4b8",
"708f0c8b-c982-47ce-8cfb-c31bc5bc7d73"
]
}
- While the
user-jwts
tool supports creating roles as an array, it does not currently support creating custom claims as an array. - By adding this capability to the
user-jwts
tool, it will make it a convenient option for testing applications that do expect custom claims with array types.
In scope
Support for creating custom claims as an array.
Examples
dotnet user-jwts create --claim companies=company1 --claim companies=company2
This could result in a token with the claim:
{
"companies": ["company1", "company2"]
}
By specifying each entry in the array as another --claim
flag, it would function similar to how the --role
flag currently works. If there is only one instance of the key, it would be a single value, and if there are multiple instances of the key, it would become an array.
Multiple Keys
dotnet user-jwts create --claim companies=company1 --claim companies=company2
Becomes:
{
"companies": ["company1", "company2"]
}
Single Key
dotnet user-jwts create --claim company=company1
Becomes:
{
"company": "company1"
}
Mixed Keys
dotnet user-jwts create --claim companies=company1 --claim companies=company2 --claim department=engineering
Becomes:
{
"companies": ["company1", "company2"],
"department": "engineering"
}