From 9a9473da9fba9b5aebc0b016c42d3fb48d0a8dc7 Mon Sep 17 00:00:00 2001 From: DavidEggenberger Date: Fri, 29 Mar 2024 17:05:06 +0100 Subject: [PATCH] updated packages web server --- .../Modules.TenantIdentity.Web.Server.csproj | 1 + .../ExecutionContextAccessor.cs | 40 ------------------- .../ExecutionContextAccessor/Registrator.cs | 27 ------------- .../WebContextAccessor/WebContextAccessor.cs | 22 ---------- .../WebContextAccessorDIRegistrator.cs | 13 ------ Source/Web/Server/Web.Server.csproj | 24 +++++------ 6 files changed, 13 insertions(+), 114 deletions(-) delete mode 100644 Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/ExecutionContextAccessor.cs delete mode 100644 Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/Registrator.cs delete mode 100644 Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs delete mode 100644 Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs diff --git a/Source/Modules/TenantIdentity/Web/Server/Modules.TenantIdentity.Web.Server.csproj b/Source/Modules/TenantIdentity/Web/Server/Modules.TenantIdentity.Web.Server.csproj index d9349abe..8a37bd2c 100644 --- a/Source/Modules/TenantIdentity/Web/Server/Modules.TenantIdentity.Web.Server.csproj +++ b/Source/Modules/TenantIdentity/Web/Server/Modules.TenantIdentity.Web.Server.csproj @@ -6,6 +6,7 @@ enable false false + diff --git a/Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/ExecutionContextAccessor.cs b/Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/ExecutionContextAccessor.cs deleted file mode 100644 index 626f6cc0..00000000 --- a/Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/ExecutionContextAccessor.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.AspNetCore.Http; -using System; - -namespace Web.Server.BuildingBlocks.ContextAccessor.ExecutionContextAccessor -{ - public class ExecutionContextAccessor : IExecutionContextAccessor - { - private HttpContext capturedHttpContext; - - public void CaptureHttpContext(HttpContext httpContext) - { - capturedHttpContext = httpContext; - } - - public Guid UserId - { - get - { - if (capturedHttpContext.User.Identity.IsAuthenticated is false) - { - return Guid.Empty; - } - return capturedHttpContext.User.GetUserId(); - } - } - - public SubscriptionPlanType SubscriptionPlan - { - get - { - if (capturedHttpContext.User.Identity.IsAuthenticated is false) - { - return SubscriptionPlanType.Free; - } - - return capturedHttpContext.User.GetSubscriptionPlanType(); - } - } - } -} diff --git a/Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/Registrator.cs b/Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/Registrator.cs deleted file mode 100644 index ec64e500..00000000 --- a/Source/Web/Server/BuildingBlocks/ContextAccessor/ExecutionContextAccessor/Registrator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace Web.Server.BuildingBlocks.ContextAccessor.ExecutionContextAccessor -{ - public static class Registrator - { - public static IServiceCollection RegisterExecutionContextAccessor(this IServiceCollection services) - { - services.AddHttpContextAccessor(); - services.AddScoped(); - return services; - } - - public static IApplicationBuilder RegisterExecutionContextAccessingMiddleware(this IApplicationBuilder applicationBuilder) - { - applicationBuilder.Use(async (context, next) => - { - var executionContextAccessor = context.RequestServices.GetService(); - executionContextAccessor.CaptureHttpContext(context); - await next(context); - }); - - return applicationBuilder; - } - } -} diff --git a/Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs b/Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs deleted file mode 100644 index 5026c977..00000000 --- a/Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.AspNetCore.Hosting.Server; -using Microsoft.AspNetCore.Hosting.Server.Features; -using Microsoft.Extensions.DependencyInjection; -using Shared.Kernel.BuildingBlocks; -using System; -using System.Linq; - -namespace Web.Server.BuildingBlocks.ContextAccessor.WebContextAccessor -{ - public class WebContextAccessor : IExecutionContext - { - public Uri BaseURI { get; set; } - public WebContextAccessor(IServiceProvider serviceProvider) - { - var server = serviceProvider.GetService(); - - var addresses = server?.Features.Get(); - - BaseURI = new Uri(addresses?.Addresses.FirstOrDefault(a => a.Contains("https")) ?? string.Empty); - } - } -} diff --git a/Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs b/Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs deleted file mode 100644 index 2717a914..00000000 --- a/Source/Web/Server/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Shared.Kernel.BuildingBlocks; - -namespace Web.Server.BuildingBlocks.ContextAccessor.WebContextAccessor -{ - public static class WebContextAccessorDIRegistrator - { - public static IServiceCollection RegisterWebContextAccessor(this IServiceCollection serviceCollection) - { - return serviceCollection.AddSingleton(); - } - } -} diff --git a/Source/Web/Server/Web.Server.csproj b/Source/Web/Server/Web.Server.csproj index 83c5438d..88d4179c 100644 --- a/Source/Web/Server/Web.Server.csproj +++ b/Source/Web/Server/Web.Server.csproj @@ -36,21 +36,21 @@ - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + +