Browse Source

Add MusicBrainz to the list of supported providers

pull/2010/head
Kévin Chalet 2 years ago
parent
commit
93b2bae008
  1. 6
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs
  2. 16
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs
  3. 36
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml
  4. 2
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xsd

6
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs

@ -135,6 +135,12 @@ public static partial class OpenIddictClientWebIntegrationHandlers
response.Content.Headers.ContentType = context.Registration.ProviderType switch
{
// MusicBrainz returns empty revocation responses declared as "text/html" responses.
//
// Since empty HTML payloads are not valid JSON nodes, the Content-Length is manually set
// to 0 to prevent OpenIddict from trying to extract a JSON payload from such responses.
ProviderTypes.MusicBrainz when response.Content.Headers.ContentLength is 0 => null,
// Reddit returns empty revocation responses declared as "application/json" responses.
//
// Since empty JSON payloads are not valid JSON nodes, the Content-Length is manually set

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

@ -1136,6 +1136,9 @@ public static partial class OpenIddictClientWebIntegrationHandlers
// Mailchimp returns the username as a custom "accountname" node:
ProviderTypes.Mailchimp => (string?) context.UserinfoResponse?["accountname"],
// Mailchimp returns the username as a custom "sub" node:
ProviderTypes.MusicBrainz => (string?) context.UserinfoResponse?["sub"],
// Nextcloud returns the username as a custom "displayname" or "display-name" node:
ProviderTypes.Nextcloud => (string?) context.UserinfoResponse?["displayname"] ??
(string?) context.UserinfoResponse?["display-name"],
@ -1216,6 +1219,9 @@ public static partial class OpenIddictClientWebIntegrationHandlers
// Mixcloud returns the user identifier as a custom "key" node:
ProviderTypes.Mixcloud => (string?) context.UserinfoResponse?["key"],
// MusicBrainz returns the user identifier as a custom "metabrainz_user_id" node:
ProviderTypes.MusicBrainz => (string?) context.UserinfoResponse?["metabrainz_user_id"],
// Notion returns the user identifier as a custom "bot/owner/user/id" node but
// requires a special capability to access this node, that may not be present:
ProviderTypes.Notion => (string?) context.UserinfoResponse?["bot"]?["owner"]?["user"]?["id"],
@ -1531,6 +1537,16 @@ public static partial class OpenIddictClientWebIntegrationHandlers
context.Request["access_type"] = settings.AccessType;
}
// By default, MusicBrainz doesn't return a refresh token but allows sending an "access_type"
// parameter to retrieve one (but it is only returned during the first authorization dance).
else if (context.Registration.ProviderType is ProviderTypes.MusicBrainz)
{
var settings = context.Registration.GetMusicBrainzSettings();
context.Request["access_type"] = settings.AccessType;
context.Request["approval_prompt"] = settings.ApprovalPrompt;
}
// Pro Santé Connect's specification requires sending an acr_values parameter containing
// the desired level of authentication (currently, only "eidas1" is supported). For more
// information, see https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000045551195.

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

@ -857,6 +857,42 @@
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▄▀▄ ██ ██ ██ ▄▄▄ █▄ ▄██ ▄▄▀██ ▄▄▀██ ▄▄▀█ ▄▄▀█▄ ▄██ ▀██ ██ ▄▄▄ ██
██ █ █ ██ ██ ██▄▄▄▀▀██ ███ █████ ▄▄▀██ ▀▀▄█ ▀▀ ██ ███ █ █ ██▀▀▀▄▄██
██ ███ ██▄▀▀▄██ ▀▀▀ █▀ ▀██ ▀▀▄██ ▀▀ ██ ██ █ ██ █▀ ▀██ ██▄ ██ ▀▀▀ ██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="MusicBrainz" Id="7b734583-1b96-4a5b-8d8c-d21d9d28b598"
Documentation="https://musicbrainz.org/doc/Development/OAuth2">
<Environment Issuer="https://musicbrainz.org/">
<Configuration AuthorizationEndpoint="https://musicbrainz.org/oauth2/authorize"
RevocationEndpoint="https://musicbrainz.org/oauth2/revoke"
TokenEndpoint="https://musicbrainz.org/oauth2/token"
UserinfoEndpoint="https://musicbrainz.org/oauth2/userinfo">
<CodeChallengeMethod Value="plain" />
<CodeChallengeMethod Value="S256" />
<GrantType Value="authorization_code" />
<GrantType Value="refresh_token" />
</Configuration>
<!--
Note: MusicBrainz requires sending the "profile" scope to be able to use the userinfo endpoint.
-->
<Scope Name="profile" Default="true" Required="true" />
</Environment>
<Setting PropertyName="AccessType" ParameterName="type" Type="String" Required="false"
Description="The value used as the 'access_type' parameter (can be set to 'offline' to retrieve a refresh token)" />
<Setting PropertyName="ApprovalPrompt" ParameterName="prompt" Type="String" Required="false"
Description="The value used as the 'approval_prompt' parameter (can be set to 'force' to display the consent form for each authorization demand)" />
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▀██ ██ ▄▄▄█▄▀█▀▄█▄▄ ▄▄██ ▄▄▀██ █████ ▄▄▄ ██ ██ ██ ▄▄▀██

2
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xsd

@ -552,7 +552,7 @@
<xs:attribute name="DisplayName" use="optional">
<xs:annotation>
<xs:documentation>The display name used in the documentation, if applicable.</xs:documentation>
<xs:documentation>The provider display name (if unspecified, the provider name is used as the display name).</xs:documentation>
</xs:annotation>
<xs:simpleType>

Loading…
Cancel
Save