Browse Source

Add Disqus to the list of supported providers

pull/2005/head
Kévin Chalet 2 years ago
parent
commit
26be4d95a7
  1. 4
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs
  2. 28
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs
  3. 19
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

4
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs

@ -374,6 +374,10 @@ public static partial class OpenIddictClientWebIntegrationHandlers
["accounts"] = context.Response["accounts"]
},
// Disqus returns a nested "response" object.
ProviderTypes.Disqus => new(context.Response["response"]?.GetNamedParameters() ??
throw new InvalidOperationException(SR.FormatID0334("response"))),
// Exact Online returns a "results" array nested in a "d" node and containing a single element.
ProviderTypes.ExactOnline => new(context.Response["d"]?["results"]?[0]?.GetNamedParameters() ??
throw new InvalidOperationException(SR.FormatID0334("d/results/0"))),

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

@ -868,6 +868,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers
context.UserinfoRequest["fields"] = string.Join(",", settings.UserFields);
}
// Disqus requires sending the client identifier (called "public
// API key" in the documentation) as part of the userinfo request.
else if (context.Registration.ProviderType is ProviderTypes.Disqus)
{
context.UserinfoRequest["api_key"] = context.Registration.ClientId;
}
// Facebook limits the number of fields returned by the userinfo endpoint
// but allows returning additional information using special parameters that
// determine what fields will be returned as part of the userinfo response.
@ -1100,9 +1107,9 @@ public static partial class OpenIddictClientWebIntegrationHandlers
context.MergedPrincipal.SetClaim(ClaimTypes.Name, issuer: issuer, value: context.Registration.ProviderType switch
{
// These providers return the username as a custom "username" node:
ProviderTypes.ArcGisOnline or ProviderTypes.Dailymotion or ProviderTypes.Discord or
ProviderTypes.DeviantArt or ProviderTypes.Lichess or ProviderTypes.Mixcloud or
ProviderTypes.Trakt or ProviderTypes.WordPress
ProviderTypes.ArcGisOnline or ProviderTypes.Dailymotion or ProviderTypes.DeviantArt or
ProviderTypes.Discord or ProviderTypes.Disqus or ProviderTypes.Lichess or
ProviderTypes.Mixcloud or ProviderTypes.Trakt or ProviderTypes.WordPress
=> (string?) context.UserinfoResponse?["username"],
// Basecamp and Harvest don't return a username so one is created using the "first_name" and "last_name" nodes:
@ -1182,12 +1189,12 @@ public static partial class OpenIddictClientWebIntegrationHandlers
=> (string?) context.UserinfoResponse?["username"],
// These providers return the user identifier as a custom "id" node:
ProviderTypes.Basecamp or ProviderTypes.Dailymotion or ProviderTypes.Deezer or
ProviderTypes.Discord or ProviderTypes.Facebook or ProviderTypes.GitHub or
ProviderTypes.Harvest or ProviderTypes.Kroger or ProviderTypes.Lichess or
ProviderTypes.Nextcloud or ProviderTypes.Patreon or ProviderTypes.Reddit or
ProviderTypes.Smartsheet or ProviderTypes.Spotify or ProviderTypes.SubscribeStar or
ProviderTypes.Twitter or ProviderTypes.Zoom
ProviderTypes.Basecamp or ProviderTypes.Dailymotion or ProviderTypes.Deezer or
ProviderTypes.Discord or ProviderTypes.Disqus or ProviderTypes.Facebook or
ProviderTypes.GitHub or ProviderTypes.Harvest or ProviderTypes.Kroger or
ProviderTypes.Lichess or ProviderTypes.Nextcloud or ProviderTypes.Patreon or
ProviderTypes.Reddit or ProviderTypes.Smartsheet or ProviderTypes.Spotify or
ProviderTypes.SubscribeStar or ProviderTypes.Twitter or ProviderTypes.Zoom
=> (string?) context.UserinfoResponse?["id"],
// Bitbucket returns the user identifier as a custom "uuid" node:
@ -1408,7 +1415,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
// The following providers are known to use comma-separated scopes instead of
// the standard format (that requires using a space as the scope separator):
ProviderTypes.Deezer or ProviderTypes.Shopify or ProviderTypes.Strava
ProviderTypes.Deezer or ProviderTypes.Disqus or
ProviderTypes.Shopify or ProviderTypes.Strava
=> string.Join(",", context.Scopes),
// The following providers are known to use plus-separated scopes instead of

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

@ -393,6 +393,25 @@
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▄▄▀█▄ ▄██ ▄▄▄ ██ ▄▄ ██ ██ ██ ▄▄▄ ██
██ ██ ██ ███▄▄▄▀▀██ ██ ██ ██ ██▄▄▄▀▀██
██ ▀▀ █▀ ▀██ ▀▀▀ ██▄▄ ▀██▄▀▀▄██ ▀▀▀ ██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="Disqus" Id="89d6777b-c22e-4421-b08b-83b1f515480c" Documentation="https://disqus.com/api/docs/auth/">
<Environment Issuer="https://disqus.com/">
<Configuration AuthorizationEndpoint="https://disqus.com/api/oauth/2.0/authorize/"
TokenEndpoint="https://disqus.com/api/oauth/2.0/access_token/"
UserinfoEndpoint="https://disqus.com/api/3.0/users/details.json">
<GrantType Value="authorization_code" />
<GrantType Value="refresh_token" />
</Configuration>
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▄▄▀██ ▄▄▄ ██ ▄▄▀██ ██ ██ ▄▄▄ █▄ ▄██ ▄▄ ██ ▀██ ██

Loading…
Cancel
Save