Browse Source

Map the "user_id" claim returned by Amazon to ClaimTypes.NameIdentifier

pull/1969/head
Kévin Chalet 2 years ago
parent
commit
885e21493f
  1. 8
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs

8
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs

@ -1150,6 +1150,10 @@ public static partial class OpenIddictClientWebIntegrationHandlers
context.MergedPrincipal.SetClaim(ClaimTypes.NameIdentifier, issuer: issuer, value: context.Registration.ProviderType switch
{
// These providers return the user identifier as a custom "user_id" node:
ProviderTypes.Amazon or ProviderTypes.HubSpot or ProviderTypes.StackExchange
=> (string?) context.UserinfoResponse?["user_id"],
// ArcGIS and Trakt don't return a user identifier and require using the username as the identifier:
ProviderTypes.ArcGisOnline or ProviderTypes.Trakt
=> (string?) context.UserinfoResponse?["username"],
@ -1172,10 +1176,6 @@ public static partial class OpenIddictClientWebIntegrationHandlers
// Fitbit returns the user identifier as a custom "encodedId" node:
ProviderTypes.Fitbit => (string?) context.UserinfoResponse?["encodedId"],
// HubSpot and StackExchange return the user identifier as a custom "user_id" node:
ProviderTypes.HubSpot or ProviderTypes.StackExchange
=> (string?) context.UserinfoResponse?["user_id"],
// Mailchimp returns the user identifier as a custom "login/login_id" node:
ProviderTypes.Mailchimp => (string?) context.UserinfoResponse?["login"]?["login_id"],

Loading…
Cancel
Save