From e40514e4408a9f0b48ef3159a6315a69b4ba5403 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 19 Jun 2025 01:56:16 +0800 Subject: [PATCH] :bug: Fix discord oidc since it has no discovery endpoint --- .../Auth/OpenId/DiscordOidcService.cs | 13 ++++++++++++- DysonNetwork.Sphere/Auth/OpenId/OidcService.cs | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DysonNetwork.Sphere/Auth/OpenId/DiscordOidcService.cs b/DysonNetwork.Sphere/Auth/OpenId/DiscordOidcService.cs index ebf6d79..c1b7366 100644 --- a/DysonNetwork.Sphere/Auth/OpenId/DiscordOidcService.cs +++ b/DysonNetwork.Sphere/Auth/OpenId/DiscordOidcService.cs @@ -32,7 +32,18 @@ public class DiscordOidcService( var queryString = string.Join("&", queryParams.Select(p => $"{p.Key}={Uri.EscapeDataString(p.Value)}")); return $"https://discord.com/api/oauth2/authorize?{queryString}"; } - + + protected override async Task GetDiscoveryDocumentAsync() + { + return new OidcDiscoveryDocument + { + AuthorizationEndpoint = "https://discord.com/oauth2/authorize", + TokenEndpoint = "https://discord.com/api/oauth2/token", + UserinfoEndpoint = "https://discord.com/api/users/@me", + JwksUri = null + }; + } + public override async Task ProcessCallbackAsync(OidcCallbackData callbackData) { var tokenResponse = await ExchangeCodeForTokensAsync(callbackData.Code); diff --git a/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs b/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs index c0a3f4b..544704a 100644 --- a/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs +++ b/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs @@ -65,7 +65,7 @@ public abstract class OidcService( /// /// Retrieves the OpenID Connect discovery document /// - protected async Task GetDiscoveryDocumentAsync() + protected virtual async Task GetDiscoveryDocumentAsync() { // Construct a cache key unique to the current provider: var cacheKey = $"oidc-discovery:{ProviderName}";