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

Claims with ClaimValueTypes.Double are not serialized as Number types #82

Closed
rubo opened this issue Jun 8, 2022 · 11 comments
Closed

Claims with ClaimValueTypes.Double are not serialized as Number types #82

rubo opened this issue Jun 8, 2022 · 11 comments

Comments

@rubo
Copy link

rubo commented Jun 8, 2022

Which version of Duende IdentityServer are you using?
6.1.0

Which version of .NET are you using?
.NET 6

Describe the bug
Claims with ClaimValueTypes.Double serialized to JSON as String instead of Number when being added to context in the IProfileService.GetProfileDataAsync(ProfileDataRequestContext context) method.

To Reproduce
Add a Claim with value type of ClaimValueTypes.Double using context.AddRequestedClaims() method in the IProfileService.GetProfileDataAsync(ProfileDataRequestContext context) implementation.

Expected behavior
The claim value in the JSON retrieved from the userinfo endpoint must be of type Number instead of String.

I presume the problem is in ClaimsExtensions.cs and/or TokenExtensions.cs.

@leastprivilege
Copy link
Member

Thanks for reporting. We will look into it.

@leastprivilege
Copy link
Member

You can use ClaimValueTypes.Integer64 instead. Can you give that a try?

@leastprivilege
Copy link
Member

Actually - the real question would be - is long.Parse() good enough for you?

I added explicit double support in this PR
DuendeSoftware/IdentityServer#911

@rubo
Copy link
Author

rubo commented Jun 10, 2022

@leastprivilege long.Parse() (ClaimValueTypes.Integer64) is not enough as I need to parse floating point numbers.

Regarding the PR: Why no changes in ClaimsExtensions.cs? I'm not sure where those extension methods are actually used but wouldn't it be consistent to have the same claim parsing logic everywhere?

@leastprivilege
Copy link
Member

Good point - that might be an oversight.

The code I changed so far is def the place where you run into your problem

@leastprivilege
Copy link
Member

tracked here:

DuendeSoftware/IdentityServer#914

@leastprivilege
Copy link
Member

leastprivilege commented Jun 20, 2022

Hey,

could you try the preview to see if it works as expected?

v6.1.1-preview.1

See here to setup the dev feed:
https://docs.duendesoftware.com/identityserver/v6/overview/packaging/#dev-builds

@rubo
Copy link
Author

rubo commented Jun 20, 2022

@leastprivilege I don't see the v6.1.1, only a handful of v6.2.0. So I tried with the v6.2.0-alpha.0.5 and it doesn't work as expected. It still returns a string.

@leastprivilege
Copy link
Member

I cleaned the feed. The preview is now available.

@rubo
Copy link
Author

rubo commented Jun 21, 2022

In v6.1.1-preview.1, it works as expected. Thank you.

@leastprivilege
Copy link
Member

OK - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants