-
Notifications
You must be signed in to change notification settings - Fork 397
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
JWT claim in the form of DateTime get extra double-quote when converted to claims #1261
Labels
Bug
Product is not functioning as expected
Customer reported
Indicates issue was opened by customer
P1
More important, prioritize highly
Milestone
Comments
brentschmaltz
added
P1
More important, prioritize highly
Customer reported
Indicates issue was opened by customer
Bug
Product is not functioning as expected
labels
Oct 4, 2019
GeoK
added a commit
that referenced
this issue
Oct 17, 2019
Currently, claims created from a deserialized JSON string might have 'System.DateTime' or ClaimValueTypes.String type, depending on the format of a datetime json string, the way how JSON string was deserialized, and json handler being used. This PR changes fixes this inconsistency, so claims that hold DateTime values always have ClaimValueTypes.String as a type. Also, by default, Newtonsoft.JSON serializer encloses some DateTime strings with quotes which results in ""dateTimeValue"" (see #1261). This behavior is changed, so that resulting string doesn't contain the double quotes. DateTime claim value (string) is now created as an UTC string represented in ISO 8061 date-time format, if a DateTime claim is added directly (via 'JwtPayload.Add()'). Replacing JObject.Parse with JObject.Load isn't introducing any performance overhead.
GeoK
added a commit
that referenced
this issue
Oct 17, 2019
Currently, claims created from a deserialized JSON string might have 'System.DateTime' (invalid claim type) or ClaimValueTypes.String type, depending on the format of a datetime json string, the way how JSON string was deserialized, and json handler being used. This PR changes fixes this inconsistency, so claims that hold DateTime values in ISO8061 datetime format will always have ClaimValueTypes.DateTime as a claim value type. DateTime strings represented in datetime formats other than ISO8061 will have ClaimValueTypes.String as a claim value type. Also, by default, Newtonsoft.JSON serializer encloses some DateTime strings with quotes which results in ""dateTimeValue"" (see #1261). This behavior is changed, so that resulting string doesn't contain the double quotes. DateTime claim value (string) is now created as an UTC string represented in ISO 8061 date-time format, if a DateTime claim is added directly (via 'JwtPayload.Add()').
GeoK
added a commit
that referenced
this issue
Oct 18, 2019
Currently, claims created from a deserialized JSON string might have 'System.DateTime' (invalid claim type) or ClaimValueTypes.String type, depending on the format of a datetime json string, the way how JSON string was deserialized, and json handler being used. This PR changes fixes this inconsistency, so claims that hold DateTime values in ISO8061 datetime format will always have ClaimValueTypes.DateTime as a claim value type. DateTime strings represented in datetime formats other than ISO8061 will have ClaimValueTypes.String as a claim value type. Also, by default, Newtonsoft.JSON serializer encloses some DateTime strings with quotes which results in ""dateTimeValue"" (see #1261). This behavior is changed, so that resulting string doesn't contain the double quotes. DateTime claim value (string) is now created as an UTC string represented in ISO 8061 date-time format, if a DateTime claim is added directly (via 'JwtPayload.Add()').
GeoK
added a commit
that referenced
this issue
Oct 18, 2019
Currently, claims created from a deserialized JSON string might have 'System.DateTime' (invalid claim type) or ClaimValueTypes.String type, depending on the format of a datetime json string, the way how JSON string was deserialized, and json handler being used. This PR changes fixes this inconsistency, so claims that hold DateTime values in ISO8061 datetime format will always have ClaimValueTypes.DateTime as a claim value type. DateTime strings represented in datetime formats other than ISO8061 will have ClaimValueTypes.String as a claim value type. Also, by default, Newtonsoft.JSON serializer encloses some DateTime strings with quotes which results in ""dateTimeValue"" (see #1261). This behavior is changed, so that resulting string doesn't contain the double quotes. DateTime claim value (string) is now created as an UTC string represented in ISO 8061 date-time format, if a DateTime claim is added directly (via 'JwtPayload.Add()').
GeoK
added a commit
that referenced
this issue
Oct 18, 2019
Currently, claims created from a deserialized JSON string might have 'System.DateTime' (invalid claim type) or ClaimValueTypes.String type, depending on the format of a datetime json string, the way how JSON string was deserialized, and json handler being used. This PR changes fixes this inconsistency, so claims that hold DateTime values in ISO8061 datetime format will always have ClaimValueTypes.DateTime as a claim value type. DateTime strings represented in datetime formats other than ISO8061 will have ClaimValueTypes.String as a claim value type. Also, by default, Newtonsoft.JSON serializer encloses some DateTime strings with quotes which results in ""dateTimeValue"" (see #1261). This behavior is changed, so that resulting string doesn't contain the double quotes. DateTime claim value (string) is now created as an UTC string represented in ISO 8061 date-time format, if a DateTime claim is added directly (via 'JwtPayload.Add()').
Thank you for reporting this issue @oliviervaillancourt. |
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
P1
More important, prioritize highly
Hi,
After an upgrade from 4.x to 5.5 of System.IdentityModel.Tokens.Jwt, we are noticing that if we read a Jwt that has a claim as a DateTime, then the value of Claim object is surrounded with double-quote.
Repro:
run this code:
Notice that the value of
claimValue
is"2019-11-15T14:31:21.6101326Z"
instead of2019-11-15T14:31:21.6101326Z
(extra double-quote).From looking into the code a little it seems that this related to the use of JsonConvert.DeserializeObject without specifying a DateFormatHandling property.
Thanks
The text was updated successfully, but these errors were encountered: