From ca2d37eb39054606c87e71bf89f0658794efee5a Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 18 Jun 2025 01:26:34 +0800 Subject: [PATCH] :sparkles: Challenge retrieve api --- DysonNetwork.Sphere/Auth/AuthController.cs | 13 +++++++++++++ .../Auth/OpenId/ConnectionController.cs | 2 +- DysonNetwork.Sphere/Auth/OpenId/OidcService.cs | 1 - DysonNetwork.Sphere/Pages/Auth/Callback.cshtml | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/DysonNetwork.Sphere/Auth/AuthController.cs b/DysonNetwork.Sphere/Auth/AuthController.cs index e252fd2..3fd885c 100644 --- a/DysonNetwork.Sphere/Auth/AuthController.cs +++ b/DysonNetwork.Sphere/Auth/AuthController.cs @@ -74,6 +74,19 @@ public class AuthController( return challenge; } + [HttpGet("challenge/{id:guid}")] + public async Task> GetChallenge([FromRoute] Guid id) + { + var challenge = await db.AuthChallenges + .Include(e => e.Account) + .ThenInclude(e => e.Profile) + .FirstOrDefaultAsync(e => e.Id == id); + + return challenge is null + ? NotFound("Auth challenge was not found.") + : challenge; + } + [HttpGet("challenge/{id:guid}/factors")] public async Task>> GetChallengeFactors([FromRoute] Guid id) { diff --git a/DysonNetwork.Sphere/Auth/OpenId/ConnectionController.cs b/DysonNetwork.Sphere/Auth/OpenId/ConnectionController.cs index c3f6257..a0ced21 100644 --- a/DysonNetwork.Sphere/Auth/OpenId/ConnectionController.cs +++ b/DysonNetwork.Sphere/Auth/OpenId/ConnectionController.cs @@ -355,7 +355,7 @@ public class ConnectionController( connection.Account, HttpContext, deviceId ?? string.Empty); - return Redirect($"/auth/callback?context={challenge.Id}"); + return Redirect($"/auth/callback?challenge={challenge.Id}"); } // Register new user diff --git a/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs b/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs index a4ddba7..c0a3f4b 100644 --- a/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs +++ b/DysonNetwork.Sphere/Auth/OpenId/OidcService.cs @@ -291,6 +291,5 @@ public class OidcCallbackData public string Code { get; set; } = ""; public string IdToken { get; set; } = ""; public string? State { get; set; } - public string? CodeVerifier { get; set; } public string? RawData { get; set; } } \ No newline at end of file diff --git a/DysonNetwork.Sphere/Pages/Auth/Callback.cshtml b/DysonNetwork.Sphere/Pages/Auth/Callback.cshtml index 9dd82d6..f152a00 100644 --- a/DysonNetwork.Sphere/Pages/Auth/Callback.cshtml +++ b/DysonNetwork.Sphere/Pages/Auth/Callback.cshtml @@ -16,7 +16,7 @@