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(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..63c1255 100644 --- a/src/Middlewares/BasePathMiddleware.cs +++ b/src/Middlewares/BasePathMiddleware.cs @@ -1,5 +1,6 @@ using Duende.IdentityServer.Extensions; using Duende.IdentityServer.Configuration; +using Duende.IdentityServer.Services; #pragma warning disable 1591 @@ -20,10 +21,10 @@ 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); + context.RequestServices.GetRequiredService().BasePath = basePath; } await _next(context); } 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 @@ - net6.0 + net8.0 enable enable true @@ -26,11 +26,11 @@ - - - - - + + + + +