问题
I followed this article where it explains how to implement a custom policy using Active Directory B2C. Everything is working great, the only concern I have is that the custom claim is returned like a serialized object. Let me explain a little bit better. I successfully created the Azure Function which return the custom claim. The encoded resulting JWT is like the following (please focus on the "userPermissions" value):
{
"exp": 1594560277,
"nbf": 1594556677,
"ver": "1.0",
"auth_time": 1594556677,
"userPermissions": "{\r\n \"permissions\":\"test1\"\r\n}" <============= HERE
}
As you can see the "userPermissions" claim is a "serialized JSON". I would like to have a JWT like the following:
{
"exp": 1594560277,
"nbf": 1594556677,
"ver": "1.0",
"auth_time": 1594556677,
"userPermissions": "test1" <============ HERE
}
As you can see the "test1" is a simple string. You may think: come on BrianEnno! This is very simple, instead of returning a "serialized JSON" your Azure Function should return a "string". Well, if I try to return a (well formed) string I received this error:
ServerError: AADB2C90261: The claims exchange 'GetPermissions' specified in step '4' returned HTTP error response that could not be parsed.
Is there a way to let it work?
来源:https://stackoverflow.com/questions/62863830/return-simple-string-claim-from-custom-policies-in-adb2c