From 2acd688ebade8643c8d43134a6875c7b36c4f493 Mon Sep 17 00:00:00 2001 From: Alex <AlexanderFux83@gmail.com> Date: Sun, 31 Mar 2024 16:26:52 -0500 Subject: [PATCH] chore: upgrade to dotnet 8.0 --- src/Dockerfile | 4 ++-- src/Helpers/OptionsHelper.cs | 4 ++-- src/Middlewares/BasePathMiddleware.cs | 2 +- src/OpenIdConnectServerMock.csproj | 12 ++++++------ src/Program.cs | 5 ++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Dockerfile b/src/Dockerfile index c01304f..e37e814 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build -FROM mcr.microsoft.com/dotnet/sdk:6.0 as source +FROM mcr.microsoft.com/dotnet/sdk:8.0 as source ARG target="Release" RUN apt-get update && apt-get install unzip -y @@ -19,7 +19,7 @@ RUN dotnet publish -c $target -o obj/docker/publish RUN cp -r /src/obj/docker/publish /OpenIdConnectServerMock # Stage 2: Release -FROM mcr.microsoft.com/dotnet/aspnet:6.0 as release +FROM mcr.microsoft.com/dotnet/aspnet:8.0 as release ARG target="Release" RUN apt-get update && apt-get install curl -y && rm -rf /var/lib/apt/lists/* diff --git a/src/Helpers/OptionsHelper.cs b/src/Helpers/OptionsHelper.cs index 3c59eb2..e92f8d0 100644 --- a/src/Helpers/OptionsHelper.cs +++ b/src/Helpers/OptionsHelper.cs @@ -11,9 +11,9 @@ public static void ConfigureOptions<T>(string optionsStr) var targetFields = typeof(T).GetFields(); var jValueValueProp = typeof(JValue).GetProperty(nameof(JValue.Value)); Array.ForEach(targetFields, k => { - if (options.ContainsKey(k.Name)) { + if (options != null && options.ContainsKey(k.Name)) { var fieldJValue = options[k.Name] as JValue; - var fieldValue = jValueValueProp.GetValue(fieldJValue); + var fieldValue = jValueValueProp?.GetValue(fieldJValue); k.SetValue(null, fieldValue); } }); diff --git a/src/Middlewares/BasePathMiddleware.cs b/src/Middlewares/BasePathMiddleware.cs index 79eb352..0abeffc 100644 --- a/src/Middlewares/BasePathMiddleware.cs +++ b/src/Middlewares/BasePathMiddleware.cs @@ -20,7 +20,7 @@ public async Task Invoke(HttpContext context) { var basePath = Config.GetAspNetServicesOptions().BasePath; var request = context.Request; - if(request.Path.Value.Length > basePath.Length) + if(request.Path.Value?.Length > basePath.Length) { request.Path = request.Path.Value.Substring(basePath.Length); context.SetIdentityServerBasePath(basePath); diff --git a/src/OpenIdConnectServerMock.csproj b/src/OpenIdConnectServerMock.csproj index 4b5c2fd..c07da1a 100644 --- a/src/OpenIdConnectServerMock.csproj +++ b/src/OpenIdConnectServerMock.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> + <TargetFramework>net8.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> @@ -26,11 +26,11 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Duende.IdentityServer" Version="6.3.6" /> - <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.24" /> - <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.24" /> - <PackageReference Include="Serilog.AspNetCore" Version="6.1.0" /> - <PackageReference Include="YamlDotNet" Version="13.7.0" /> + <PackageReference Include="Duende.IdentityServer" Version="7.0.3" /> + <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.3" /> + <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.3" /> + <PackageReference Include="Serilog.AspNetCore" Version="8.0.1" /> + <PackageReference Include="YamlDotNet" Version="15.1.2" /> </ItemGroup> </Project> diff --git a/src/Program.cs b/src/Program.cs index 1f20854..640acd8 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -1,5 +1,4 @@ -using Duende.IdentityServer.Hosting; -using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.FileProviders; using OpenIdConnectServer; using OpenIdConnectServer.Helpers; using OpenIdConnectServer.JsonConverters; @@ -36,7 +35,7 @@ }); builder.Services - .AddIdentityServer(options => + .AddIdentityServerBuilder(options => { var configuredOptions = Config.GetServerOptions(); MergeHelper.Merge(configuredOptions, options);