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

Add back support for Guid values in JwtPayload... #2440

Merged

Conversation

KevinH-MS
Copy link
Contributor

@KevinH-MS KevinH-MS commented Jan 9, 2024

Add back support for Guid values in JwtPayload...

Changes JsonSerializerPrimitves to serialize claim values of type Guid as string (rather than throwing an Exception)...

Description

In versions of Microsoft.IdentityModel.Tokens < 7.0.0-preview4, claim values could have values of type Guid and would be serialized successfully. This appears to have been regressed with the rewrite of the serializer implementation.

I checked the round-trip behavior with older versions, and it seems that the serialized strings are subsequently deserialized as string (by JwtPayload.Deserialize), so I left the behavior asymmetric (rather than try-parsing all string values as Guid).

Fixes #2439

@KevinH-MS
Copy link
Contributor Author

KevinH-MS commented Jan 9, 2024

Tagging @brentschmaltz ... Seems like a difference between Newtonsoft <-> System.Text.Json. I went ahead and added a quirk for this since it seemed trivial, but let me know if this behavior was deliberately changed.

In my situation, it'd be a lot easier to make the fix here as opposed to fixing and upgrading the library I'm calling that's adding the claim with the Guid value...seems like preserving the old behavior might save others some headache as well...

Copy link
Contributor

@keegan-caruso keegan-caruso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Copy link
Collaborator

@jennyf19 jennyf19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jennyf19
Copy link
Collaborator

@KevinH-MS appreciate the added tests.

@keegan-caruso keegan-caruso merged commit ecd1912 into AzureAD:dev Jan 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] JwtPayload no longer supports Guid claim values
3 participants