Skip to content

Commit

Permalink
Add JsonSerializerPrimitives.TryAllStringClaimsAsDateTime to 7x. (#2734)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaytak authored Jul 19, 2024
1 parent 74d8a82 commit e65fcb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ internal static string GetStringClaimValueType(string str)

internal static string GetStringClaimValueType(string str, string claimType)
{
if (!string.IsNullOrEmpty(claimType) && !AppContextSwitches.TryAllStringClaimsAsDateTime && JsonSerializerPrimitives.IsKnownToNotBeDateTime(claimType))
if (!string.IsNullOrEmpty(claimType) && !JsonSerializerPrimitives.TryAllStringClaimsAsDateTime() && JsonSerializerPrimitives.IsKnownToNotBeDateTime(claimType))
return ClaimValueTypes.String;

if (DateTime.TryParse(str, out DateTime dateTimeValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,11 @@ internal static string ReadStringOrNumberAsString(ref Utf8JsonReader reader, str
return retVal;
}

public static bool TryAllStringClaimsAsDateTime()
{
return AppContextSwitches.TryAllStringClaimsAsDateTime;
}

/// <summary>
/// This is a non-exhaustive list of claim types that are not expected to be DateTime values
/// sourced from expected Entra V1 and V2 claims, OpenID Connect claims, and a selection of
Expand Down

0 comments on commit e65fcb2

Please sign in to comment.