Skip to content

Commit

Permalink
Update ValidateIdentityModelToken to use TryGetPayloadValue() with Di…
Browse files Browse the repository at this point in the history
…ctionary<TKey, TValue> instead of ImmutableDictionary<TKey, TValue>
  • Loading branch information
kevinchalet committed Sep 5, 2023
1 parent 23d8d9b commit ca1784f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,13 @@ JsonWebTokenTypes.Jwt or JsonWebTokenTypes.Prefixes.Application + JsonWebTokenTy
});

// 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<string, string[]> 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<string, string[]> is not supported, the value
// is retrieved as a Dictionary<string, string[]>, which is supported by both Wilson 6.x and 7.x.
if (token.TryGetPayloadValue(Claims.Private.ClaimDestinationsMap, out Dictionary<string, string[]> destinations))
{
context.Principal.SetDestinations(destinations);
context.Principal.SetDestinations(destinations.ToImmutableDictionary());
}

context.Logger.LogTrace(SR.GetResourceString(SR.ID6001), context.Token, context.Principal.Claims);
Expand Down

0 comments on commit ca1784f

Please sign in to comment.