Browse Source

Add Tumblr to the list of supported providers

pull/1827/head
Kévin Chalet 3 years ago
parent
commit
74a143a136
  1. 8
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs
  2. 4
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs
  3. 20
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

8
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;
}
}

4
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<string, OpenIddictParameter>(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
};

20
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

@ -1127,6 +1127,26 @@
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▄▄ ▄▄██ ██ ██ ▄▀▄ ██ ▄▄▀██ █████ ▄▄▀██
███ ████ ██ ██ █ █ ██ ▄▄▀██ █████ ▀▀▄██
███ ████▄▀▀▄██ ███ ██ ▀▀ ██ ▀▀ ██ ██ ██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="Tumblr" Id="546a1f33-f660-4aa6-9cce-ef950d3ca6f8"
Documentation="https://www.tumblr.com/docs/en/api/v2#oauth2-authorization">
<Environment Issuer="https://www.tumblr.com/">
<Configuration AuthorizationEndpoint="https://www.tumblr.com/oauth2/authorize"
TokenEndpoint="https://api.tumblr.com/v2/oauth2/token"
UserinfoEndpoint="https://api.tumblr.com/v2/user/info">
<GrantType Value="authorization_code" />
<GrantType Value="refresh_token" />
</Configuration>
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█▄▄ ▄▄██ ███ █▄ ▄█▄▄ ▄▄█▄▄ ▄▄██ ▄▄▄██ ▄▄▀██

Loading…
Cancel
Save