diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs index c80b4abb..c8283752 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs @@ -104,8 +104,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers if (context.Registration.ProviderType is ProviderTypes.AlibabaCloud or ProviderTypes.Apple or - ProviderTypes.FaceIt or ProviderTypes.LinkedIn or - ProviderTypes.QuickBooksOnline) + ProviderTypes.Discord or ProviderTypes.FaceIt or + ProviderTypes.LinkedIn or ProviderTypes.QuickBooksOnline) { context.Configuration.GrantTypesSupported.Add(GrantTypes.AuthorizationCode); context.Configuration.GrantTypesSupported.Add(GrantTypes.RefreshToken); @@ -277,7 +277,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers // configuration and thus are treated as OAuth 2.0-only providers by the OpenIddict client. // To avoid that, the "openid" scope is manually added to indicate OpenID Connect is supported. else if (context.Registration.ProviderType is - ProviderTypes.EpicGames or ProviderTypes.EveOnline or ProviderTypes.Xero) + ProviderTypes.Discord or ProviderTypes.EpicGames or + ProviderTypes.EveOnline or ProviderTypes.Xero) { context.Configuration.ScopesSupported.Add(Scopes.OpenId); } @@ -345,6 +346,23 @@ public static partial class OpenIddictClientWebIntegrationHandlers ClientAuthenticationMethods.ClientSecretPost); } + // Discord doesn't return the list of supported client authentication methods in its server + // configuration but is known to support both "client_secret_basic" and "client_secret_post". + else if (context.Registration.ProviderType is ProviderTypes.Discord) + { + context.Configuration.TokenEndpointAuthMethodsSupported.Add( + ClientAuthenticationMethods.ClientSecretBasic); + + context.Configuration.TokenEndpointAuthMethodsSupported.Add( + ClientAuthenticationMethods.ClientSecretPost); + + context.Configuration.RevocationEndpointAuthMethodsSupported.Add( + ClientAuthenticationMethods.ClientSecretBasic); + + context.Configuration.RevocationEndpointAuthMethodsSupported.Add( + ClientAuthenticationMethods.ClientSecretPost); + } + // Google doesn't properly implement the device authorization grant, doesn't support // basic client authentication for the device authorization endpoint and returns // a generic "invalid_request" error when using "client_secret_basic" instead of @@ -435,6 +453,17 @@ public static partial class OpenIddictClientWebIntegrationHandlers context.Registration.Issuer, new Uri("oidc/logout", UriKind.Relative)); } + // While Discord supports OpenID Connect discovery, the configuration document doesn't include the + // address of the revocation endpoint. To work around that, the endpoint URI is manually added here. + // + // Note: the userinfo endpoint is returned in the configuration document but is replaced here to + // use the same endpoint as the one used in previous OpenIddict versions for compatibility reasons. + else if (context.Registration.ProviderType is ProviderTypes.Discord) + { + context.Configuration.RevocationEndpoint = new Uri("https://discord.com/api/oauth2/token/revoke", UriKind.Absolute); + context.Configuration.UserInfoEndpoint = new Uri("https://discord.com/api/users/@me", UriKind.Absolute); + } + // While Huawei supports OpenID Connect discovery, the configuration // document doesn't return the address of the device authorization endpoint. // To work around that, the endpoint URI is manually added here. diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs index 7266eeff..56005bac 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs @@ -917,10 +917,10 @@ public static partial class OpenIddictClientWebIntegrationHandlers context.DisableBackchannelIdentityTokenNonceValidation = context.Registration.ProviderType switch { // These providers don't include the nonce in their identity tokens: - ProviderTypes.Asana or ProviderTypes.DocuSign or - ProviderTypes.Dropbox or ProviderTypes.FaceIt or - ProviderTypes.LinkedIn or ProviderTypes.QuickBooksOnline or - ProviderTypes.WorldId => true, + ProviderTypes.Asana or ProviderTypes.Discord or + ProviderTypes.DocuSign or ProviderTypes.Dropbox or + ProviderTypes.FaceIt or ProviderTypes.LinkedIn or + ProviderTypes.QuickBooksOnline or ProviderTypes.WorldId => true, _ => context.DisableBackchannelIdentityTokenNonceValidation }; @@ -1044,6 +1044,10 @@ public static partial class OpenIddictClientWebIntegrationHandlers context.DisableUserInfoValidation = context.Registration.ProviderType switch { + // The Discord provider uses a custom API endpoint instead of the standard OpenID + // Connect userinfo endpoint for compatibility with previous OpenIddict versions. + ProviderTypes.Discord => true, + // SuperOffice doesn't offer a standard OpenID Connect userinfo endpoint. ProviderTypes.SuperOffice => true, diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml index f31dbfa1..336d5c74 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml @@ -714,16 +714,6 @@ - - - - - - -