From 74a143a136913dfc304bbbd1f964c0f5c421f27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sat, 15 Jul 2023 17:17:41 +0200 Subject: [PATCH] Add Tumblr to the list of supported providers --- ...ctClientWebIntegrationHandlers.Exchange.cs | 8 ++++++++ ...ctClientWebIntegrationHandlers.Userinfo.cs | 4 ++++ ...penIddictClientWebIntegrationProviders.xml | 20 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs index 89eb3dcf..55d85315 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs @@ -342,6 +342,14 @@ public static partial class OpenIddictClientWebIntegrationHandlers context.Response["expires"] = null; } + // Note: Tumblr returns a non-standard "id_token: false" node that collides + // with the standard id_token parameter used in OpenID Connect. To ensure + // the response is not rejected, the "id_token" node is manually removed. + else if (context.Registration.ProviderType is ProviderTypes.Tumblr) + { + context.Response["id_token"] = null; + } + return default; } } diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs index 29e741ae..84f4c88f 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs @@ -317,6 +317,10 @@ public static partial class OpenIddictClientWebIntegrationHandlers let name = $"{parameter.Key}_{node.Key}" select new KeyValuePair(name, node.Value)), + // Tumblr returns a nested "user" object that is itself nested in a "response" node. + ProviderTypes.Tumblr => new(context.Response["response"]?["user"]?.GetNamedParameters() ?? + throw new InvalidOperationException(SR.FormatID0334("response/user"))), + _ => context.Response }; diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml index b8f8dccf..45ed3f5b 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml @@ -1127,6 +1127,26 @@ + + + + + + + + + + +