From 5a22807410491caffdf2479d8dd851eb633a3f2d Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 2 Nov 2024 21:23:49 +0100 Subject: [PATCH] fix: don't pass CancellationToken to method that shouldn't abort also add license header to project --- .../Authentication/DiscordAuthController.cs | 16 ++++++---------- Foxnouns.Backend/Services/RemoteAuthService.cs | 1 - Foxnouns.NET.sln.DotSettings | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Foxnouns.Backend/Controllers/Authentication/DiscordAuthController.cs b/Foxnouns.Backend/Controllers/Authentication/DiscordAuthController.cs index 344d8ff..54ca24b 100644 --- a/Foxnouns.Backend/Controllers/Authentication/DiscordAuthController.cs +++ b/Foxnouns.Backend/Controllers/Authentication/DiscordAuthController.cs @@ -28,18 +28,15 @@ public class DiscordAuthController( // TODO: duplicating attribute doesn't work, find another way to mark both as possible response // leaving it here for documentation purposes [ProducesResponseType(StatusCodes.Status200OK)] - public async Task CallbackAsync( - [FromBody] AuthController.CallbackRequest req, - CancellationToken ct = default - ) + public async Task CallbackAsync([FromBody] AuthController.CallbackRequest req) { CheckRequirements(); - await keyCacheService.ValidateAuthStateAsync(req.State, ct); + await keyCacheService.ValidateAuthStateAsync(req.State); - var remoteUser = await remoteAuthService.RequestDiscordTokenAsync(req.Code, req.State, ct); - var user = await authService.AuthenticateUserAsync(AuthType.Discord, remoteUser.Id, ct: ct); + var remoteUser = await remoteAuthService.RequestDiscordTokenAsync(req.Code); + var user = await authService.AuthenticateUserAsync(AuthType.Discord, remoteUser.Id); if (user != null) - return Ok(await GenerateUserTokenAsync(user, ct)); + return Ok(await GenerateUserTokenAsync(user)); _logger.Debug( "Discord user {Username} ({Id}) authenticated with no local account", @@ -51,8 +48,7 @@ public class DiscordAuthController( await keyCacheService.SetKeyAsync( $"discord:{ticket}", remoteUser, - Duration.FromMinutes(20), - ct + Duration.FromMinutes(20) ); return Ok( diff --git a/Foxnouns.Backend/Services/RemoteAuthService.cs b/Foxnouns.Backend/Services/RemoteAuthService.cs index 505029d..91a2dc5 100644 --- a/Foxnouns.Backend/Services/RemoteAuthService.cs +++ b/Foxnouns.Backend/Services/RemoteAuthService.cs @@ -13,7 +13,6 @@ public class RemoteAuthService(Config config, ILogger logger) public async Task RequestDiscordTokenAsync( string code, - string state, CancellationToken ct = default ) { diff --git a/Foxnouns.NET.sln.DotSettings b/Foxnouns.NET.sln.DotSettings index 69e6273..e9d37e2 100644 --- a/Foxnouns.NET.sln.DotSettings +++ b/Foxnouns.NET.sln.DotSettings @@ -1,3 +1,18 @@  + Copyright (C) 2023-present sam/u1f320 (vulpine.solutions) + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. + True True True \ No newline at end of file