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

[Bug] breaking change in 7: TryGetPayloadValue() changes the type of returned object (compared with Identity.Model 6.x) for the "aud" claim #2328

Closed
jmprieur opened this issue Sep 26, 2023 · 1 comment
Assignees
Labels
Internal Indicates issue was opened by the IdentityModel team P1 More important, prioritize highly

Comments

@jmprieur
Copy link
Contributor

jmprieur commented Sep 26, 2023

Which version of Microsoft.IdentityModel are you using?
Note that to get help, you need to run the latest version.

Where is the issue?

  • [ x ] M.IM.JsonWebTokens

Is this a new or an existing app?
Following-up the removal of NewtonSoft.json, the actual claim type returned by TryGetPayloadValue when passing object, is different. For instance:

If we are trying to get the value of the audience claim("aud"), when there is a single audience, previously subjectToken.TryGetPayloadValue("aud", out object claimValue) would retum claimValue as a string.
With Wilson 7.0.0, the claimValue retumed as a IList.

It is important for customers to maintain the same type.

Repro

subjectToken.TryGetPayloadValue("aud", out object claimValue);
Assert.True(claimValue is string);

Expected behavior
The claimValue for "aud" should be a string

Actual behavior
The claimValue for "aud" is now an IList (with one element)

Possible solution
Return a string if there is only one audience.

Workaround

subjectToken.TryGetPayloadValue("aud", out string claimValue);
Assert.True(claimValue is string);
@jmprieur jmprieur changed the title [Bug] Regression [Bug] breaking change in 7: TryGetPayloadValue() changes the type of returned object (compared with Identity.Model 6.x) for the "aud" claim Sep 26, 2023
@brentschmaltz brentschmaltz self-assigned this Sep 26, 2023
@brentschmaltz brentschmaltz added Internal Indicates issue was opened by the IdentityModel team P1 More important, prioritize highly labels Sep 26, 2023
@brentschmaltz
Copy link
Member

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Indicates issue was opened by the IdentityModel team P1 More important, prioritize highly
Projects
None yet
Development

No branches or pull requests

2 participants