From ca1784faabb3ca3d5889648d2cbd90f2c50f2343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Tue, 5 Sep 2023 17:16:43 +0200 Subject: [PATCH] Update ValidateIdentityModelToken to use TryGetPayloadValue() with Dictionary instead of ImmutableDictionary --- .../OpenIddictServerHandlers.Protection.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs index 05cede50..ba9c8a00 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs @@ -408,9 +408,13 @@ public static partial class OpenIddictServerHandlers }); // Restore the claim destinations from the special oi_cl_dstn claim (represented as a dictionary/JSON object). - if (token.TryGetPayloadValue(Claims.Private.ClaimDestinationsMap, out ImmutableDictionary destinations)) + // + // Note: starting in 7.0, Wilson no longer uses JSON.NET and supports a limited set of types for the + // TryGetPayloadValue() API. Since ImmutableDictionary is not supported, the value + // is retrieved as a Dictionary, which is supported by both Wilson 6.x and 7.x. + if (token.TryGetPayloadValue(Claims.Private.ClaimDestinationsMap, out Dictionary destinations)) { - context.Principal.SetDestinations(destinations); + context.Principal.SetDestinations(destinations.ToImmutableDictionary()); } context.Logger.LogTrace(SR.GetResourceString(SR.ID6001), context.Token, context.Principal.Claims);