Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonWebToken.TryGetPayloadValue() can no longer be used with dictionary types #2246

Closed
kevinchalet opened this issue Aug 22, 2023 · 2 comments
Assignees
Labels
Bug Product is not functioning as expected Customer reported Indicates issue was opened by customer P0 Totally broken or major security hole. Stop and fix. Regression

Comments

@kevinchalet
Copy link
Contributor

Consider the following JWT payload:

{
  "a": {
    "prop1": [
      "value1",
      "value2"
    ]
  },
  "exp": 1692706803,
  "iat": 1692703203,
  "nbf": 1692703203
}

The following snippet works just fine on 7.0.0-preview but fails on 7.0.0-preview3 (TryGetPayloadValue returns false):

var handler = new JsonWebTokenHandler();
var token = handler.ReadJsonWebToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjp7InByb3AxIjpbInZh" +
    "bHVlMSIsInZhbHVlMiJdfSwiZXhwIjoxNjkyNzA2ODAzLCJpYXQiOjE2OTI3MDMyMDMsIm5iZiI6MTY5MjcwMzIwM30.dZ" +
    "lSC8OLOKUvSCXu9uZFb91NQwWBJ7dwSxEn-WA2RVEBW1l3Wu2wdobOuezivtzX9OWpgYyvzog4nHfD-Yco4Ou5qYqN0JbB" +
    "fU7gESA95iDtDhbDzVB8T3W3T7k3a1LHwVNZbBGTnZQMgF447R-euIlMcGY6p5WQFLyFPZjBOKW2nlwh0MYQQ-5mZpEgzE" +
    "pdcHVOjdO0pV1EJTKFjHuiUuFsI6d6i3dLOQYX2JpaclT--pTFqs4Nx1O8gn9bKbfKTpGlpy2CpJJLmmzKqsLWtrXL0eSD" +
    "QQBK0ynvd6ssRARH_L3f9Hf05oBRqiqO3ukWw8qAoBE-ZF6906gYnwMcYA");

if (token.TryGetPayloadValue("a", out Dictionary<string, string[]> dictionary))
{
    Console.WriteLine("The dictionary has been correctly deserialized.");
}

/cc @brentschmaltz @jennyf19

@jennyf19 jennyf19 added this to the 7.0.0-preview4 milestone Aug 22, 2023
@jennyf19 jennyf19 added Customer reported Indicates issue was opened by customer Bug Product is not functioning as expected P0 Totally broken or major security hole. Stop and fix. Regression labels Aug 22, 2023
@brentschmaltz
Copy link
Member

@kevinchalet in our haste to remove our internal newtonsoft, we have some regressions, we will fix them.

@jennyf19
Copy link
Collaborator

Included in preview4 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Product is not functioning as expected Customer reported Indicates issue was opened by customer P0 Totally broken or major security hole. Stop and fix. Regression
Projects
None yet
Development

No branches or pull requests

4 participants