Return simple string claim from custom policies in ADB2C

一笑奈何 提交于 2020-08-10 01:12:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!