From c1c09c5b51db9a3fb032b22e38cc500ac162cfcb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 13 Aug 2023 14:08:13 -0400 Subject: [PATCH 1/3] Update to .NET 8 preview 7 --- build/Version.props | 2 +- .../Tgstation.Server.Host.Console.csproj | 2 +- .../Tgstation.Server.Host.Service.csproj | 8 ++++---- .../Tgstation.Server.Host.Watchdog.csproj | 2 +- .../Tgstation.Server.Host.csproj | 12 +++++------- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/build/Version.props b/build/Version.props index fef8a1b33a..678573c06c 100644 --- a/build/Version.props +++ b/build/Version.props @@ -17,7 +17,7 @@ netstandard2.0 8 - https://download.visualstudio.microsoft.com/download/pr/e5db48f5-99c6-42ca-804a-85b89ae09671/b5594181b347a9a77246e3645916bd0e/dotnet-hosting-8.0.0-preview.6.23329.11-win.exe + https://download.visualstudio.microsoft.com/download/pr/e465df26-2f50-432f-a588-51c7682fd9b1/9efca17f575afd387aa9b02fb3dfb7e1/dotnet-hosting-8.0.0-preview.7.23375.9-win.exe 11.0.2 https://ftp.osuosl.org/pub/mariadb/mariadb-11.0.2/winx64-packages/mariadb-11.0.2-winx64.msi diff --git a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj index ebe2348e40..791ab81994 100644 --- a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj +++ b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj index 1e102db995..cecc519479 100644 --- a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj +++ b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj @@ -19,15 +19,15 @@ - + - + - + - + diff --git a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj index bfd4955b3b..df0f2e6999 100644 --- a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj +++ b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 429d93d279..fdac8b2b1c 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -71,9 +71,9 @@ - + - + @@ -111,13 +111,11 @@ - - - + - + - + From 2fa35a403bb7c14740937b505b534c4f2e29c602 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 13 Aug 2023 14:09:36 -0400 Subject: [PATCH 2/3] Fix code scanning issue --- src/Tgstation.Server.Api/ApiHeaders.cs | 3 ++- src/Tgstation.Server.Host/Models/ChatChannel.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Api/ApiHeaders.cs b/src/Tgstation.Server.Api/ApiHeaders.cs index 7dc1d79e7e..7ee712130a 100644 --- a/src/Tgstation.Server.Api/ApiHeaders.cs +++ b/src/Tgstation.Server.Api/ApiHeaders.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Net.Http.Headers; using System.Net.Mime; @@ -331,7 +332,7 @@ namespace Tgstation.Server.Api instanceId ??= InstanceId; if (instanceId.HasValue) - headers.Add(InstanceIdHeader, instanceId.ToString()); + headers.Add(InstanceIdHeader, instanceId.Value.ToString(CultureInfo.InvariantCulture)); } } } diff --git a/src/Tgstation.Server.Host/Models/ChatChannel.cs b/src/Tgstation.Server.Host/Models/ChatChannel.cs index 902c80bdb9..8519ffffdb 100644 --- a/src/Tgstation.Server.Host/Models/ChatChannel.cs +++ b/src/Tgstation.Server.Host/Models/ChatChannel.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using System.Globalization; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; @@ -41,7 +42,7 @@ namespace Tgstation.Server.Host.Models /// The converted . public Api.Models.ChatChannel ToApi(ChatProvider chatProvider) => new Api.Models.ChatChannel { - ChannelData = chatProvider == ChatProvider.Discord ? DiscordChannelId.ToString() : IrcChannel, + ChannelData = chatProvider == ChatProvider.Discord ? DiscordChannelId.Value.ToString(CultureInfo.InvariantCulture) : IrcChannel, #pragma warning disable CS0618 IrcChannel = IrcChannel, DiscordChannelId = DiscordChannelId, From 651c810496bf26f784f2fbcf48c9e0b7f9f8766d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 13 Aug 2023 20:58:44 -0400 Subject: [PATCH 3/3] Fix issue with token claim mapping --- src/Tgstation.Server.Host/Core/Application.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 591953c0d8..5718d2cd1d 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.IdentityModel.Tokens.Jwt; using System.Linq; using Cyberboss.AspNetCore.AsyncInitializer; @@ -224,6 +223,7 @@ namespace Tgstation.Server.Host.Core // this line isn't actually run until the first request is made // at that point tokenFactory will be populated jwtBearerOptions.TokenValidationParameters = tokenFactory.ValidationParameters; + jwtBearerOptions.MapInboundClaims = false; jwtBearerOptions.Events = new JwtBearerEvents { // Application is our composition root so this monstrosity of a line is okay @@ -238,11 +238,6 @@ namespace Tgstation.Server.Host.Core }; }); - // WARNING: STATIC CODE - // fucking prevents converting 'sub' to M$ bs - // can't be done in the above lambda, that's too late - JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); - // add mvc, configure the json serializer settings services .AddMvc(options =>