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] byte[] values in JwtPayload et al. are serialized as arrays instead of base64. #2524

Closed
1 of 14 tasks
LeadAssimilator opened this issue Mar 14, 2024 · 2 comments · Fixed by #2690
Closed
1 of 14 tasks
Assignees
Labels
IdentityModel8x Future breaking issues/features for IdentityModel 8x Serialization
Milestone

Comments

@LeadAssimilator
Copy link

Which version of Microsoft.IdentityModel are you using?
Microsoft.IdentityModel 7.x.x

Where is the issue?

  • M.IM.JsonWebTokens
  • M.IM.KeyVaultExtensions
  • M.IM.Logging
  • M.IM.ManagedKeyVaultSecurityKey
  • M.IM.Protocols
  • M.IM.Protocols.OpenIdConnect
  • M.IM.Protocols.SignedHttpRequest
  • M.IM.Protocols.WsFederation
  • M.IM.TestExtensions
  • M.IM.Tokens
  • M.IM.Tokens.Saml
  • M.IM.Validators
  • M.IM.Xml
  • S.IM.Tokens.Jwt
  • Other (please describe)

Is this a new or an existing app?
The app is in production and I have upgraded to a new version of Microsoft.IdentityModel.*

Repro

Console.WriteLine(new JwtPayload { { "Fail", new byte[] { 0x21, 0x62, 0x36, 0x34 } } }.SerializeToJson());
//6.x.x - {"Fail":"IWI2NA=="}
//7.x.x - {"Fail":["33","98","54","52"]}

Expected behavior
byte[] arrays are serialized as base64.

Actual behavior
byte[] arrays are serialized as arrays.

Possible solution

Additional context / logs / screenshots / links to code
Prior to 7.0.0, byte[] arrays were serialized as base64. This is both the default behavior of System.Text.Json and Json.NET. However since 7.0.0 this changed to serialize them as arrays. If this was intentional, it is an undocumented breaking change affecting backwards compatibility and interoperability with other systems expecting the older format!

@keegan-caruso
Copy link
Contributor

@brentschmaltz , can you take a look please?

@brentschmaltz
Copy link
Member

@LeadAssimilator @keegan-caruso I will have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IdentityModel8x Future breaking issues/features for IdentityModel 8x Serialization
Projects
None yet
4 participants