From bad9c11f48108100ba488779239448e745a6c5ba Mon Sep 17 00:00:00 2001 From: Jonathan Law Date: Fri, 15 Mar 2024 11:52:35 -0400 Subject: [PATCH] Add Clever to the list of supported providers --- ...enIddictClientWebIntegrationHandlers.Userinfo.cs | 12 ++++++++++++ .../OpenIddictClientWebIntegrationProviders.xml | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs index 487eda29..85d2bcee 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs @@ -478,6 +478,18 @@ public static partial class OpenIddictClientWebIntegrationHandlers { context.Response[Claims.Subject] = (string?) context.Response[Claims.Subject]; } + + // Note: Clever returns a non-standard "name" claim formatted as a JSON object. + else if (context.Registration.ProviderType is ProviderTypes.Clever) + { + var name = context.Response[Claims.Name]?.GetNamedParameters(); + if (name is not null) + { + context.Response[Claims.Name] = $"{name["first"]} {name["last"]}"; + context.Response[Claims.FamilyName] = name["last"]; + context.Response[Claims.GivenName] = name["first"]; + } + } return default; } diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml index 7592beef..23fd7dcb 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml @@ -309,6 +309,19 @@ + + + + + +