From 22114d67e48f782f98384657a647e068464b609e Mon Sep 17 00:00:00 2001 From: DavidEggenberger Date: Sun, 24 Mar 2024 21:07:59 +0100 Subject: [PATCH] upgrade to .net8 --- .../Features/Modules.Channels.Features.csproj | 2 +- .../Modules.Channels.IntegrationEvents.csproj | 2 +- .../Client/Modules.Channels.Web.Client.csproj | 2 +- .../DTOs/Modules.Channels.Web.Shared.csproj | 2 +- .../Server/Controllers/ChannelsController.cs | 2 +- .../Server/Modules.Channels.Web.Server.csproj | 2 +- .../Server/Modules.LandingPages.Server.csproj | 2 +- .../Modules.Subscriptions.Features.csproj | 2 +- ...les.Subscriptions.IntegrationEvents.csproj | 2 +- .../Modules.Subscriptions.Web.Client.csproj | 2 +- .../Modules.Subscriptions.Web.Shared.csproj | 2 +- .../Modules.Subscriptions.Web.Server.csproj | 2 +- .../Application/Queries/GetClaimsForUser.cs | 2 +- .../UserClaimsPrincipalFactory.cs | 2 +- .../Modules.TenantIdentity.Features.csproj | 2 +- ...es.TenantIdentity.IntegrationEvents.csproj | 2 +- .../Modules.TenantIdentity.Web.Client.csproj | 2 +- .../Modules.TenantIdentity.Web.Shared.csproj | 2 +- .../ExternalLoginCallbackController.cs | 2 +- .../Modules.TenantIdentity.Web.Server.csproj | 2 +- .../Web/Server/TenantIdentityModuleStartup.cs | 2 +- .../CQRS/DomainEvent/DomainEventDispatcher.cs | 3 +- .../DomainEvent/IDomainEventDispatcher.cs | 2 +- .../CQRS/DomainEvent/IDomainEventHandler.cs | 2 +- .../IIntegrationEventDispatcher.cs | 2 +- .../IIntegrationEventHandler.cs | 2 +- .../IntegrationEventDispatcher.cs | 2 +- .../Shared/Features/Domain/AggregateRoot.cs | 23 +++++++ .../Attributes/JoiningTableAttribute.cs | 0 .../Attributes/ValueObjectAttribute.cs | 0 .../{DomainKernel => Domain}/Entity.cs | 3 +- .../Exceptions}/DomainException.cs | 2 +- .../InvalidEntityDeleteException.cs | 4 +- .../Exceptions/NotAllowedException.cs | 0 Source/Shared/Features/Domain/IDomainEvent.cs | 6 ++ .../{DomainKernel => Domain}/ValueObject.cs | 2 +- .../Features/DomainKernel/AggregateRoot.cs | 9 --- .../DomainKernel/Interfaces/IDomainEvent.cs | 6 -- .../Interfaces/IIntegrationEvent.cs | 6 -- .../EFCore/ExecutionContextInterceptor.cs | 24 ++++++++ .../MultiTenancyEntityConfiguration.cs | 1 + Source/Shared/Features/EFCore/Registrator.cs | 26 ++++++++ .../EFCore/TransactionScopeMiddleware.cs | 18 ++++++ .../Configuration/IModuleConfiguration.cs | 6 ++ .../Modules/Configuration/Registrator.cs | 37 ++++++++++++ .../{ModuleRegistrator.cs => Registrator.cs} | 2 +- ...tedBaseController.cs => BaseController.cs} | 6 +- .../Server/ExecutionContext/Registrator.cs | 24 ++++++++ .../ServerExecutionContext.cs | 58 ++++++++++++++++++ .../ServerExecutionContextMiddleware.cs | 17 ++++++ .../Features/Server/ServerExecutionBase.cs | 30 ++++++++++ Source/Shared/Features/Shared.Features.csproj | 11 ++-- .../Auth/AuthorizationDIRegistrator.cs | 3 +- .../Auth}/Constants/ClaimConstants.cs | 2 +- .../Auth}/Constants/PolicyConstants.cs | 2 +- .../Constants/SubscriptionPlanConstants.cs | 2 +- .../Auth/Constants/TenantRoleConstants.cs | 8 +++ .../Auth/CreatorPolicyHandler.cs | 1 + .../BuildingBlocks/IExecutionContext.cs | 22 +++++++ .../BuildingBlocks/IIntegrationEvent.cs | 12 ++++ .../BuildingBlocks/IWebContextAccessor.cs | 7 --- .../Excceptions/NoValidatorFoundException.cs | 6 -- .../Excceptions/NoValidatorFoundException.cs | 6 ++ .../ModelValidation/IValidationService.cs | 2 +- .../ModelValidation/Registrator.cs | 2 +- .../ModelValidation/ValidationService.cs | 4 +- .../ValidationServiceResult.cs | 2 +- .../Shared/Kernel/Components/BaseComponent.cs | 17 ------ .../Kernel/Constants/EndpointConstants.cs | 13 ---- .../Modules/SubscriptionsEndpointConstants.cs | 17 ++++++ .../Modules/TenantIdentityEndpointContants.cs | 20 +++++++ .../Kernel/Constants/SignalRConstants.cs | 7 --- .../Kernel/Constants/TenantRoleConstants.cs | 8 --- .../ClaimsPrincipal/ClaimNotFoundException.cs | 6 -- .../ClaimsPrincipal/NoRoleClaimException.cs | 6 -- .../UserIdClaimNotFoundException.cs | 6 -- .../ClaimsPrincipalExtensions.cs | 60 +++++++++++++++++++ .../Exceptions/ClaimNotFoundException.cs | 6 ++ .../Exceptions/NoRoleClaimException.cs | 6 ++ .../UserIdClaimNotFoundException.cs | 6 ++ .../Extensions/ClaimsPrincipalExtensions.cs | 49 --------------- Source/Shared/Kernel/Shared.Kernel.csproj | 10 ++-- .../APIVersioningMdwRegistrator.cs | 14 ----- ...sioningDIRegistrator.cs => Registrator.cs} | 14 ++++- .../AntiforgeryTokenDIRegistrator.cs | 19 ------ .../AntiforgeryToken/Registrator.cs | 19 ++++++ .../WebContextAccessor/WebContextAccessor.cs | 2 +- .../WebContextAccessorDIRegistrator.cs | 2 +- ...ndlingMdwRegistrator.cs => Registrator.cs} | 4 +- .../Logging/LoggingDIRegistrator.cs | 14 ----- .../Logging/LoggingMdwRegistrator.cs | 12 ---- .../BuildingBlocks/Logging/Registrator.cs | 20 +++++++ ...idationDIRegistrator.cs => Registrator.cs} | 5 +- .../WebServer/BuildingBlocks/Registrator.cs | 30 ++++------ ...eadersMdwRegistrator.cs => Registrator.cs} | 7 ++- ...SwaggerDIRegistrator.cs => Registrator.cs} | 17 +++++- .../Swagger/SwaggerMdwRegistrator.cs | 19 ------ Source/Web/WebServer/Web.Server.csproj | 6 +- .../Antiforgery/AntiForgeryTokenInput.razor | 0 .../Antiforgery/AntiforgeryTokenService.cs | 4 +- .../Auth}/AuthorizedHandler.cs | 4 +- .../Components/LoginDisplayComponent.razor | 0 .../LoginDisplayComponent.razor.css | 0 .../Auth}/Components/ProfileComponent.razor | 0 .../Components/ProfileComponent.razor.css | 0 .../Auth}/Components/RedirectToLogin.razor | 0 .../Auth}/HostAuthenticationStateProvider.cs | 7 ++- .../Layouts/BaseLayout.razor | 0 .../Layouts/BaseLayout.razor.cs | 0 .../Layouts/BaseLayout.razor.css | 0 .../Layouts/MainLayout.razor | 0 .../Layouts/MainLayout.razor.cs | 0 .../Layouts/MainLayout.razor.css | 0 .../Layouts/MainLayoutMenu/NavMenu.razor | 0 .../Layouts/MainLayoutMenu/NavMenu.razor.css | 0 .../SelectedTeamDisplayComp.razor | 0 .../SelectedTeamDisplayComp.razor.css | 0 .../MainLayoutMenu/TeamsOverviewComp.razor | 0 .../MainLayoutMenu/TeamsOverviewComp.razor.cs | 0 .../TeamsOverviewComp.razor.css | 0 .../Layouts/TopicLayout.razor | 0 .../Wrappers/AuthCascadingWrapper.razor | 0 .../Wrappers/ExceptionHandlingWrapper.razor | 0 .../Wrappers/NotificationWrapper.razor | 0 .../Wrappers/SignalRWrapper.razor | 0 .../Wrappers/TenantCascadingWrapper.razor | 0 Source/Web/WebWasmClient/Program.cs | 4 +- Source/Web/WebWasmClient/Web.Client.csproj | 4 +- .../ArchitectureTests.csproj | 2 +- 129 files changed, 592 insertions(+), 331 deletions(-) create mode 100644 Source/Shared/Features/Domain/AggregateRoot.cs rename Source/Shared/Features/{DomainKernel => Domain}/Attributes/JoiningTableAttribute.cs (100%) rename Source/Shared/Features/{DomainKernel => Domain}/Attributes/ValueObjectAttribute.cs (100%) rename Source/Shared/Features/{DomainKernel => Domain}/Entity.cs (94%) rename Source/Shared/Features/{DomainKernel => Domain/Exceptions}/DomainException.cs (75%) rename Source/Shared/Features/{DomainKernel => Domain}/Exceptions/InvalidEntityDeleteException.cs (65%) rename Source/Shared/Features/{DomainKernel => Domain}/Exceptions/NotAllowedException.cs (100%) create mode 100644 Source/Shared/Features/Domain/IDomainEvent.cs rename Source/Shared/Features/{DomainKernel => Domain}/ValueObject.cs (97%) delete mode 100644 Source/Shared/Features/DomainKernel/AggregateRoot.cs delete mode 100644 Source/Shared/Features/DomainKernel/Interfaces/IDomainEvent.cs delete mode 100644 Source/Shared/Features/DomainKernel/Interfaces/IIntegrationEvent.cs create mode 100644 Source/Shared/Features/EFCore/ExecutionContextInterceptor.cs create mode 100644 Source/Shared/Features/EFCore/Registrator.cs create mode 100644 Source/Shared/Features/EFCore/TransactionScopeMiddleware.cs create mode 100644 Source/Shared/Features/Modules/Configuration/IModuleConfiguration.cs create mode 100644 Source/Shared/Features/Modules/Configuration/Registrator.cs rename Source/Shared/Features/Modules/{ModuleRegistrator.cs => Registrator.cs} (97%) rename Source/Shared/Features/Server/{AuthenticatedBaseController.cs => BaseController.cs} (84%) create mode 100644 Source/Shared/Features/Server/ExecutionContext/Registrator.cs create mode 100644 Source/Shared/Features/Server/ExecutionContext/ServerExecutionContext.cs create mode 100644 Source/Shared/Features/Server/ExecutionContext/ServerExecutionContextMiddleware.cs create mode 100644 Source/Shared/Features/Server/ServerExecutionBase.cs rename Source/Shared/Kernel/{ => BuildingBlocks/Auth}/Constants/ClaimConstants.cs (91%) rename Source/Shared/Kernel/{ => BuildingBlocks/Auth}/Constants/PolicyConstants.cs (89%) rename Source/Shared/Kernel/{ => BuildingBlocks/Auth}/Constants/SubscriptionPlanConstants.cs (80%) create mode 100644 Source/Shared/Kernel/BuildingBlocks/Auth/Constants/TenantRoleConstants.cs create mode 100644 Source/Shared/Kernel/BuildingBlocks/IExecutionContext.cs create mode 100644 Source/Shared/Kernel/BuildingBlocks/IIntegrationEvent.cs delete mode 100644 Source/Shared/Kernel/BuildingBlocks/IWebContextAccessor.cs delete mode 100644 Source/Shared/Kernel/BuildingBlocks/ModelValidation/Excceptions/NoValidatorFoundException.cs create mode 100644 Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/Excceptions/NoValidatorFoundException.cs rename Source/Shared/Kernel/BuildingBlocks/{ => Services}/ModelValidation/IValidationService.cs (57%) rename Source/Shared/Kernel/BuildingBlocks/{ => Services}/ModelValidation/Registrator.cs (82%) rename Source/Shared/Kernel/BuildingBlocks/{ => Services}/ModelValidation/ValidationService.cs (92%) rename Source/Shared/Kernel/BuildingBlocks/{ => Services}/ModelValidation/ValidationServiceResult.cs (68%) delete mode 100644 Source/Shared/Kernel/Components/BaseComponent.cs delete mode 100644 Source/Shared/Kernel/Constants/EndpointConstants.cs create mode 100644 Source/Shared/Kernel/Constants/Modules/SubscriptionsEndpointConstants.cs create mode 100644 Source/Shared/Kernel/Constants/Modules/TenantIdentityEndpointContants.cs delete mode 100644 Source/Shared/Kernel/Constants/SignalRConstants.cs delete mode 100644 Source/Shared/Kernel/Constants/TenantRoleConstants.cs delete mode 100644 Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/ClaimNotFoundException.cs delete mode 100644 Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/NoRoleClaimException.cs delete mode 100644 Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/UserIdClaimNotFoundException.cs create mode 100644 Source/Shared/Kernel/Extensions/ClaimsPrincipal/ClaimsPrincipalExtensions.cs create mode 100644 Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/ClaimNotFoundException.cs create mode 100644 Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/NoRoleClaimException.cs create mode 100644 Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/UserIdClaimNotFoundException.cs delete mode 100644 Source/Shared/Kernel/Extensions/ClaimsPrincipalExtensions.cs delete mode 100644 Source/Web/WebServer/BuildingBlocks/APIVersioning/APIVersioningMdwRegistrator.cs rename Source/Web/WebServer/BuildingBlocks/APIVersioning/{APIVersioningDIRegistrator.cs => Registrator.cs} (54%) delete mode 100644 Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/AntiforgeryTokenDIRegistrator.cs create mode 100644 Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/Registrator.cs rename Source/Web/WebServer/BuildingBlocks/ExceptionHandling/{ExceptionHandlingMdwRegistrator.cs => Registrator.cs} (55%) delete mode 100644 Source/Web/WebServer/BuildingBlocks/Logging/LoggingDIRegistrator.cs delete mode 100644 Source/Web/WebServer/BuildingBlocks/Logging/LoggingMdwRegistrator.cs create mode 100644 Source/Web/WebServer/BuildingBlocks/Logging/Registrator.cs rename Source/Web/WebServer/BuildingBlocks/ModelValidation/{ModelValidationDIRegistrator.cs => Registrator.cs} (86%) rename Source/Web/WebServer/BuildingBlocks/SecurityHeaders/{SecurityHeadersMdwRegistrator.cs => Registrator.cs} (79%) rename Source/Web/WebServer/BuildingBlocks/Swagger/{SwaggerDIRegistrator.cs => Registrator.cs} (62%) delete mode 100644 Source/Web/WebServer/BuildingBlocks/Swagger/SwaggerMdwRegistrator.cs rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/Antiforgery/AntiForgeryTokenInput.razor (100%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/Antiforgery/AntiforgeryTokenService.cs (79%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/AuthorizedHandler.cs (93%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/Components/LoginDisplayComponent.razor (100%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/Components/LoginDisplayComponent.razor.css (100%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/Components/ProfileComponent.razor (100%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/Components/ProfileComponent.razor.css (100%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/Components/RedirectToLogin.razor (100%) rename Source/Web/WebWasmClient/{Authentication => BuildingBlocks/Auth}/HostAuthenticationStateProvider.cs (94%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/BaseLayout.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/BaseLayout.razor.cs (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/BaseLayout.razor.css (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayout.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayout.razor.cs (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayout.razor.css (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayoutMenu/NavMenu.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayoutMenu/NavMenu.razor.css (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor.css (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayoutMenu/TeamsOverviewComp.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.cs (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.css (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Layouts/TopicLayout.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Wrappers/AuthCascadingWrapper.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Wrappers/ExceptionHandlingWrapper.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Wrappers/NotificationWrapper.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Wrappers/SignalRWrapper.razor (100%) rename Source/Web/WebWasmClient/{ => BuildingBlocks}/Wrappers/TenantCascadingWrapper.razor (100%) diff --git a/Source/Modules/Channels/Features/Modules.Channels.Features.csproj b/Source/Modules/Channels/Features/Modules.Channels.Features.csproj index 68a2ec7a..a74bc4e3 100644 --- a/Source/Modules/Channels/Features/Modules.Channels.Features.csproj +++ b/Source/Modules/Channels/Features/Modules.Channels.Features.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Channels/IntegrationEvents/Modules.Channels.IntegrationEvents.csproj b/Source/Modules/Channels/IntegrationEvents/Modules.Channels.IntegrationEvents.csproj index 132c02c5..30402ac0 100644 --- a/Source/Modules/Channels/IntegrationEvents/Modules.Channels.IntegrationEvents.csproj +++ b/Source/Modules/Channels/IntegrationEvents/Modules.Channels.IntegrationEvents.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Channels/Web/Client/Modules.Channels.Web.Client.csproj b/Source/Modules/Channels/Web/Client/Modules.Channels.Web.Client.csproj index 081968ec..4a7ca4c3 100644 --- a/Source/Modules/Channels/Web/Client/Modules.Channels.Web.Client.csproj +++ b/Source/Modules/Channels/Web/Client/Modules.Channels.Web.Client.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Channels/Web/DTOs/Modules.Channels.Web.Shared.csproj b/Source/Modules/Channels/Web/DTOs/Modules.Channels.Web.Shared.csproj index 132c02c5..30402ac0 100644 --- a/Source/Modules/Channels/Web/DTOs/Modules.Channels.Web.Shared.csproj +++ b/Source/Modules/Channels/Web/DTOs/Modules.Channels.Web.Shared.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Channels/Web/Server/Controllers/ChannelsController.cs b/Source/Modules/Channels/Web/Server/Controllers/ChannelsController.cs index 5eccf5dc..0fed253b 100644 --- a/Source/Modules/Channels/Web/Server/Controllers/ChannelsController.cs +++ b/Source/Modules/Channels/Web/Server/Controllers/ChannelsController.cs @@ -9,7 +9,7 @@ using Modules.Channels.Features.Aggregates.ChannelAggregate.Application.Commands; using Modules.Channels.Features.Aggregates.ChannelAggregate.Application.Queries; using Shared.Kernel.BuildingBlocks.Authorization.Attributes; -using Shared.Kernel.Constants; +using Shared.Kernel.BuildingBlocks.Auth.Constants; namespace Modules.Channels.Web.Server.Controllers { diff --git a/Source/Modules/Channels/Web/Server/Modules.Channels.Web.Server.csproj b/Source/Modules/Channels/Web/Server/Modules.Channels.Web.Server.csproj index 739d145a..54a09b94 100644 --- a/Source/Modules/Channels/Web/Server/Modules.Channels.Web.Server.csproj +++ b/Source/Modules/Channels/Web/Server/Modules.Channels.Web.Server.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable false diff --git a/Source/Modules/LandingPages/Web/Server/Modules.LandingPages.Server.csproj b/Source/Modules/LandingPages/Web/Server/Modules.LandingPages.Server.csproj index 58e5b213..fb50f612 100644 --- a/Source/Modules/LandingPages/Web/Server/Modules.LandingPages.Server.csproj +++ b/Source/Modules/LandingPages/Web/Server/Modules.LandingPages.Server.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable true diff --git a/Source/Modules/Subscription/Features/Modules.Subscription.Features/Modules.Subscriptions.Features.csproj b/Source/Modules/Subscription/Features/Modules.Subscription.Features/Modules.Subscriptions.Features.csproj index 31795451..e4a66dc7 100644 --- a/Source/Modules/Subscription/Features/Modules.Subscription.Features/Modules.Subscriptions.Features.csproj +++ b/Source/Modules/Subscription/Features/Modules.Subscription.Features/Modules.Subscriptions.Features.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Subscription/IntegrationEvents/Modules.Subscriptions.IntegrationEvents.csproj b/Source/Modules/Subscription/IntegrationEvents/Modules.Subscriptions.IntegrationEvents.csproj index 132c02c5..30402ac0 100644 --- a/Source/Modules/Subscription/IntegrationEvents/Modules.Subscriptions.IntegrationEvents.csproj +++ b/Source/Modules/Subscription/IntegrationEvents/Modules.Subscriptions.IntegrationEvents.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Subscription/Web/Client/Modules.Subscriptions.Web.Client.csproj b/Source/Modules/Subscription/Web/Client/Modules.Subscriptions.Web.Client.csproj index c3a274b0..cf028367 100644 --- a/Source/Modules/Subscription/Web/Client/Modules.Subscriptions.Web.Client.csproj +++ b/Source/Modules/Subscription/Web/Client/Modules.Subscriptions.Web.Client.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Subscription/Web/DTOs/Modules.Subscriptions.Web.Shared.csproj b/Source/Modules/Subscription/Web/DTOs/Modules.Subscriptions.Web.Shared.csproj index 132c02c5..30402ac0 100644 --- a/Source/Modules/Subscription/Web/DTOs/Modules.Subscriptions.Web.Shared.csproj +++ b/Source/Modules/Subscription/Web/DTOs/Modules.Subscriptions.Web.Shared.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/Subscription/Web/Server/Modules.Subscriptions.Web.Server.csproj b/Source/Modules/Subscription/Web/Server/Modules.Subscriptions.Web.Server.csproj index 9b5d9ac7..7dc002b9 100644 --- a/Source/Modules/Subscription/Web/Server/Modules.Subscriptions.Web.Server.csproj +++ b/Source/Modules/Subscription/Web/Server/Modules.Subscriptions.Web.Server.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable false diff --git a/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Aggregates/UserAggregate/Application/Queries/GetClaimsForUser.cs b/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Aggregates/UserAggregate/Application/Queries/GetClaimsForUser.cs index bdc382f5..6feb363c 100644 --- a/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Aggregates/UserAggregate/Application/Queries/GetClaimsForUser.cs +++ b/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Aggregates/UserAggregate/Application/Queries/GetClaimsForUser.cs @@ -1,6 +1,6 @@ using Modules.TenantIdentity.Features.Infrastructure.EFCore; using Shared.Features.CQRS.Query; -using Shared.SharedKernel.Constants; +using Shared.Kernel.BuildingBlocks.Auth.Constants; using System; using System.Collections.Generic; using System.Linq; diff --git a/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Infrastructure/UserClaimsPrincipalFactory.cs b/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Infrastructure/UserClaimsPrincipalFactory.cs index 33e16483..e469d361 100644 --- a/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Infrastructure/UserClaimsPrincipalFactory.cs +++ b/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Infrastructure/UserClaimsPrincipalFactory.cs @@ -5,7 +5,7 @@ using Modules.TenantIdentity.Features.Aggregates.UserAggregate; using System.Threading.Tasks; using System.Collections.Generic; -using Shared.SharedKernel.Constants; +using Shared.Kernel.BuildingBlocks.Auth.Constants; namespace Modules.TenantIdentity.Features.Infrastructure { diff --git a/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Modules.TenantIdentity.Features.csproj b/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Modules.TenantIdentity.Features.csproj index 7800b0a8..4493f0c3 100644 --- a/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Modules.TenantIdentity.Features.csproj +++ b/Source/Modules/TenantIdentity/Features/Modules.TenantIdentity.Features/Modules.TenantIdentity.Features.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 diff --git a/Source/Modules/TenantIdentity/IntegrationEvents/Modules.TenantIdentity.IntegrationEvents.csproj b/Source/Modules/TenantIdentity/IntegrationEvents/Modules.TenantIdentity.IntegrationEvents.csproj index 132c02c5..30402ac0 100644 --- a/Source/Modules/TenantIdentity/IntegrationEvents/Modules.TenantIdentity.IntegrationEvents.csproj +++ b/Source/Modules/TenantIdentity/IntegrationEvents/Modules.TenantIdentity.IntegrationEvents.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/TenantIdentity/Web/Client/Modules.TenantIdentity.Web.Client.csproj b/Source/Modules/TenantIdentity/Web/Client/Modules.TenantIdentity.Web.Client.csproj index f4192fa6..1cd93ce6 100644 --- a/Source/Modules/TenantIdentity/Web/Client/Modules.TenantIdentity.Web.Client.csproj +++ b/Source/Modules/TenantIdentity/Web/Client/Modules.TenantIdentity.Web.Client.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable diff --git a/Source/Modules/TenantIdentity/Web/DTOs/Modules.TenantIdentity.Web.Shared.csproj b/Source/Modules/TenantIdentity/Web/DTOs/Modules.TenantIdentity.Web.Shared.csproj index 132c02c5..30402ac0 100644 --- a/Source/Modules/TenantIdentity/Web/DTOs/Modules.TenantIdentity.Web.Shared.csproj +++ b/Source/Modules/TenantIdentity/Web/DTOs/Modules.TenantIdentity.Web.Shared.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Source/Modules/TenantIdentity/Web/Server/Controllers/ExternalLoginCallbackController.cs b/Source/Modules/TenantIdentity/Web/Server/Controllers/ExternalLoginCallbackController.cs index 8b3c256e..360e8dd6 100644 --- a/Source/Modules/TenantIdentity/Web/Server/Controllers/ExternalLoginCallbackController.cs +++ b/Source/Modules/TenantIdentity/Web/Server/Controllers/ExternalLoginCallbackController.cs @@ -5,9 +5,9 @@ using Shared.Modules.Layers.Application.CQRS.Command; using Module.Shared.Modules.Layers.Features; using Shared.Modules.Layers.Features.Identity.Commands; -using Shared.SharedKernel.Constants; using ApplicationUserManager = Shared.Modules.Layers.Features.Identity.ApplicationUserManager; using Shared.SharedKernel.Exstensions; +using Shared.Kernel.BuildingBlocks.Auth.Constants; namespace WebServer.Controllers.Identity { 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 399f7c09..e57b8964 100644 --- a/Source/Modules/TenantIdentity/Web/Server/Modules.TenantIdentity.Web.Server.csproj +++ b/Source/Modules/TenantIdentity/Web/Server/Modules.TenantIdentity.Web.Server.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable false diff --git a/Source/Modules/TenantIdentity/Web/Server/TenantIdentityModuleStartup.cs b/Source/Modules/TenantIdentity/Web/Server/TenantIdentityModuleStartup.cs index e9dba850..54431979 100644 --- a/Source/Modules/TenantIdentity/Web/Server/TenantIdentityModuleStartup.cs +++ b/Source/Modules/TenantIdentity/Web/Server/TenantIdentityModuleStartup.cs @@ -10,8 +10,8 @@ using Microsoft.Extensions.Hosting; using Modules.TenantIdentity.Layers.Features; using Shared.Features.Modules; +using Shared.Kernel.BuildingBlocks.Auth.Constants; using Shared.Kernel.BuildingBlocks.Authorization.Services; -using Shared.SharedKernel.Constants; using System.Reflection; using System.Security.Claims; diff --git a/Source/Shared/Features/CQRS/DomainEvent/DomainEventDispatcher.cs b/Source/Shared/Features/CQRS/DomainEvent/DomainEventDispatcher.cs index e16dd18d..c2365721 100644 --- a/Source/Shared/Features/CQRS/DomainEvent/DomainEventDispatcher.cs +++ b/Source/Shared/Features/CQRS/DomainEvent/DomainEventDispatcher.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -using Shared.Features.DomainKernel.Interfaces; +using Shared.Features.Domain; +using Shared.Kernel.BuildingBlocks; namespace Shared.Features.CQRS.DomainEvent { diff --git a/Source/Shared/Features/CQRS/DomainEvent/IDomainEventDispatcher.cs b/Source/Shared/Features/CQRS/DomainEvent/IDomainEventDispatcher.cs index f705251c..d8aed78d 100644 --- a/Source/Shared/Features/CQRS/DomainEvent/IDomainEventDispatcher.cs +++ b/Source/Shared/Features/CQRS/DomainEvent/IDomainEventDispatcher.cs @@ -1,4 +1,4 @@ -using Shared.Features.DomainKernel.Interfaces; +using Shared.Features.Domain; namespace Shared.Features.CQRS.DomainEvent { diff --git a/Source/Shared/Features/CQRS/DomainEvent/IDomainEventHandler.cs b/Source/Shared/Features/CQRS/DomainEvent/IDomainEventHandler.cs index 9fb591f1..75f8e1d9 100644 --- a/Source/Shared/Features/CQRS/DomainEvent/IDomainEventHandler.cs +++ b/Source/Shared/Features/CQRS/DomainEvent/IDomainEventHandler.cs @@ -1,4 +1,4 @@ -using Shared.Features.DomainKernel.Interfaces; +using Shared.Features.Domain; namespace Shared.Features.CQRS.DomainEvent { diff --git a/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventDispatcher.cs b/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventDispatcher.cs index 3d4bb16c..7129475e 100644 --- a/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventDispatcher.cs +++ b/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventDispatcher.cs @@ -1,4 +1,4 @@ -using Shared.Features.DomainKernel.Interfaces; +using Shared.Kernel.BuildingBlocks; namespace Shared.Features.CQRS.IntegrationEvent { diff --git a/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventHandler.cs b/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventHandler.cs index 18d57872..ad72ef3a 100644 --- a/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventHandler.cs +++ b/Source/Shared/Features/CQRS/IntegrationEvent/IIntegrationEventHandler.cs @@ -1,4 +1,4 @@ -using Shared.Features.DomainKernel.Interfaces; +using Shared.Kernel.BuildingBlocks; namespace Shared.Features.CQRS.IntegrationEvent { diff --git a/Source/Shared/Features/CQRS/IntegrationEvent/IntegrationEventDispatcher.cs b/Source/Shared/Features/CQRS/IntegrationEvent/IntegrationEventDispatcher.cs index 56ff3ae0..990e74c9 100644 --- a/Source/Shared/Features/CQRS/IntegrationEvent/IntegrationEventDispatcher.cs +++ b/Source/Shared/Features/CQRS/IntegrationEvent/IntegrationEventDispatcher.cs @@ -1,5 +1,5 @@ using Microsoft.Extensions.DependencyInjection; -using Shared.Features.DomainKernel.Interfaces; +using Shared.Kernel.BuildingBlocks; namespace Shared.Features.CQRS.IntegrationEvent { diff --git a/Source/Shared/Features/Domain/AggregateRoot.cs b/Source/Shared/Features/Domain/AggregateRoot.cs new file mode 100644 index 00000000..18db6ce7 --- /dev/null +++ b/Source/Shared/Features/Domain/AggregateRoot.cs @@ -0,0 +1,23 @@ +using SendGrid.Helpers.Errors.Model; +using Shared.Kernel.BuildingBlocks.Auth.DomainKernel; +using Shared.Kernel.BuildingBlocks; +using Shared.SharedKernel.Interfaces; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Shared.Features.Domain +{ + public class AggregateRoot : Entity, ITenantIdentifiable + { + [NotMapped] + public IExecutionContext ExecutionContext { get; set; } + public virtual Guid TenantId { get; set; } + + public void ThrowIfCallerIsNotInRole(TenantRole role) + { + if (ExecutionContext.TenantRole != role) + { + throw new UnauthorizedException(); + } + } + } +} diff --git a/Source/Shared/Features/DomainKernel/Attributes/JoiningTableAttribute.cs b/Source/Shared/Features/Domain/Attributes/JoiningTableAttribute.cs similarity index 100% rename from Source/Shared/Features/DomainKernel/Attributes/JoiningTableAttribute.cs rename to Source/Shared/Features/Domain/Attributes/JoiningTableAttribute.cs diff --git a/Source/Shared/Features/DomainKernel/Attributes/ValueObjectAttribute.cs b/Source/Shared/Features/Domain/Attributes/ValueObjectAttribute.cs similarity index 100% rename from Source/Shared/Features/DomainKernel/Attributes/ValueObjectAttribute.cs rename to Source/Shared/Features/Domain/Attributes/ValueObjectAttribute.cs diff --git a/Source/Shared/Features/DomainKernel/Entity.cs b/Source/Shared/Features/Domain/Entity.cs similarity index 94% rename from Source/Shared/Features/DomainKernel/Entity.cs rename to Source/Shared/Features/Domain/Entity.cs index 5379e5d1..2989d216 100644 --- a/Source/Shared/Features/DomainKernel/Entity.cs +++ b/Source/Shared/Features/Domain/Entity.cs @@ -1,8 +1,7 @@ using Shared.Features.DomainKernel.Exceptions; -using Shared.Features.DomainKernel.Interfaces; using Shared.SharedKernel.Interfaces; -namespace Shared.Features.DomainKernel +namespace Shared.Features.Domain { public abstract class Entity : IAuditable, IIdentifiable, IConcurrent { diff --git a/Source/Shared/Features/DomainKernel/DomainException.cs b/Source/Shared/Features/Domain/Exceptions/DomainException.cs similarity index 75% rename from Source/Shared/Features/DomainKernel/DomainException.cs rename to Source/Shared/Features/Domain/Exceptions/DomainException.cs index 980edee3..ddf9b419 100644 --- a/Source/Shared/Features/DomainKernel/DomainException.cs +++ b/Source/Shared/Features/Domain/Exceptions/DomainException.cs @@ -1,4 +1,4 @@ -namespace Shared.Features.DomainKernel +namespace Shared.Features.Domain.Exceptions { public class DomainException : Exception { diff --git a/Source/Shared/Features/DomainKernel/Exceptions/InvalidEntityDeleteException.cs b/Source/Shared/Features/Domain/Exceptions/InvalidEntityDeleteException.cs similarity index 65% rename from Source/Shared/Features/DomainKernel/Exceptions/InvalidEntityDeleteException.cs rename to Source/Shared/Features/Domain/Exceptions/InvalidEntityDeleteException.cs index 43025668..3abd8065 100644 --- a/Source/Shared/Features/DomainKernel/Exceptions/InvalidEntityDeleteException.cs +++ b/Source/Shared/Features/Domain/Exceptions/InvalidEntityDeleteException.cs @@ -1,4 +1,6 @@ -namespace Shared.Features.DomainKernel.Exceptions +using Shared.Features.Domain.Exceptions; + +namespace Shared.Features.DomainKernel.Exceptions { public class InvalidEntityDeleteException : DomainException { diff --git a/Source/Shared/Features/DomainKernel/Exceptions/NotAllowedException.cs b/Source/Shared/Features/Domain/Exceptions/NotAllowedException.cs similarity index 100% rename from Source/Shared/Features/DomainKernel/Exceptions/NotAllowedException.cs rename to Source/Shared/Features/Domain/Exceptions/NotAllowedException.cs diff --git a/Source/Shared/Features/Domain/IDomainEvent.cs b/Source/Shared/Features/Domain/IDomainEvent.cs new file mode 100644 index 00000000..c14baf75 --- /dev/null +++ b/Source/Shared/Features/Domain/IDomainEvent.cs @@ -0,0 +1,6 @@ +namespace Shared.Features.Domain +{ + public interface IDomainEvent + { + } +} diff --git a/Source/Shared/Features/DomainKernel/ValueObject.cs b/Source/Shared/Features/Domain/ValueObject.cs similarity index 97% rename from Source/Shared/Features/DomainKernel/ValueObject.cs rename to Source/Shared/Features/Domain/ValueObject.cs index 2e052851..2dc84792 100644 --- a/Source/Shared/Features/DomainKernel/ValueObject.cs +++ b/Source/Shared/Features/Domain/ValueObject.cs @@ -1,4 +1,4 @@ -namespace Shared.Features.DomainKernel +namespace Shared.Features.Domain { public abstract class ValueObject { diff --git a/Source/Shared/Features/DomainKernel/AggregateRoot.cs b/Source/Shared/Features/DomainKernel/AggregateRoot.cs deleted file mode 100644 index 3574e1c6..00000000 --- a/Source/Shared/Features/DomainKernel/AggregateRoot.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Shared.SharedKernel.Interfaces; - -namespace Shared.Features.DomainKernel -{ - public class AggregateRoot : Entity, ITenantIdentifiable - { - public Guid TenantId { get; set; } - } -} diff --git a/Source/Shared/Features/DomainKernel/Interfaces/IDomainEvent.cs b/Source/Shared/Features/DomainKernel/Interfaces/IDomainEvent.cs deleted file mode 100644 index 15c74186..00000000 --- a/Source/Shared/Features/DomainKernel/Interfaces/IDomainEvent.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Shared.Features.DomainKernel.Interfaces -{ - public interface IDomainEvent - { - } -} diff --git a/Source/Shared/Features/DomainKernel/Interfaces/IIntegrationEvent.cs b/Source/Shared/Features/DomainKernel/Interfaces/IIntegrationEvent.cs deleted file mode 100644 index 962f6340..00000000 --- a/Source/Shared/Features/DomainKernel/Interfaces/IIntegrationEvent.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Shared.Features.DomainKernel.Interfaces -{ - public interface IIntegrationEvent - { - } -} diff --git a/Source/Shared/Features/EFCore/ExecutionContextInterceptor.cs b/Source/Shared/Features/EFCore/ExecutionContextInterceptor.cs new file mode 100644 index 00000000..538fc2e4 --- /dev/null +++ b/Source/Shared/Features/EFCore/ExecutionContextInterceptor.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Shared.Features.Domain; +using Shared.Kernel.BuildingBlocks; + +namespace Shared.Features.EFCore +{ + public class ExecutionContextInterceptor : SaveChangesInterceptor + { + public object InitializedInstance( + MaterializationInterceptionData materializationData, + object instance) + { + if (instance is AggregateRoot aggregateRoot) + { + aggregateRoot.ExecutionContext = materializationData + .Context + .GetService(); + } + + return instance; + } + } +} diff --git a/Source/Shared/Features/EFCore/MultiTenancy/MultiTenancyEntityConfiguration.cs b/Source/Shared/Features/EFCore/MultiTenancy/MultiTenancyEntityConfiguration.cs index 2cff96ba..038196ab 100644 --- a/Source/Shared/Features/EFCore/MultiTenancy/MultiTenancyEntityConfiguration.cs +++ b/Source/Shared/Features/EFCore/MultiTenancy/MultiTenancyEntityConfiguration.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Shared.Features.Domain; using Shared.Features.DomainKernel; using Shared.Features.DomainKernel.Attributes; using System.Reflection; diff --git a/Source/Shared/Features/EFCore/Registrator.cs b/Source/Shared/Features/EFCore/Registrator.cs new file mode 100644 index 00000000..5394ff52 --- /dev/null +++ b/Source/Shared/Features/EFCore/Registrator.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Shared.Features.EFCore.Configuration; +using Shared.Features.Modules.Configuration; + +namespace Shared.Features.EFCore +{ + public static class Registrator + { + public static IServiceCollection AddEFCore(this IServiceCollection services, IConfiguration configuration) + { + services.RegisterModuleConfiguration(configuration); + services.AddScoped(); + + return services; + } + + public static IApplicationBuilder UseEFCoreMiddleware(this IApplicationBuilder app) + { + app.UseMiddleware(); + + return app; + } + } +} diff --git a/Source/Shared/Features/EFCore/TransactionScopeMiddleware.cs b/Source/Shared/Features/EFCore/TransactionScopeMiddleware.cs new file mode 100644 index 00000000..5f1ca997 --- /dev/null +++ b/Source/Shared/Features/EFCore/TransactionScopeMiddleware.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Http; +using System.Transactions; + +namespace Shared.Features.EFCore +{ + public class TransactionScopeMiddleware : IMiddleware + { + public async Task InvokeAsync(HttpContext context, RequestDelegate next) + { + using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await next(context); + + scope.Complete(); + } + } + } +} \ No newline at end of file diff --git a/Source/Shared/Features/Modules/Configuration/IModuleConfiguration.cs b/Source/Shared/Features/Modules/Configuration/IModuleConfiguration.cs new file mode 100644 index 00000000..f3a93120 --- /dev/null +++ b/Source/Shared/Features/Modules/Configuration/IModuleConfiguration.cs @@ -0,0 +1,6 @@ +namespace Shared.Features.Modules.Configuration +{ + public interface IModuleConfiguration + { + } +} diff --git a/Source/Shared/Features/Modules/Configuration/Registrator.cs b/Source/Shared/Features/Modules/Configuration/Registrator.cs new file mode 100644 index 00000000..f039d65b --- /dev/null +++ b/Source/Shared/Features/Modules/Configuration/Registrator.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace Shared.Features.Modules.Configuration +{ + public static class Registrator + { + public static IServiceCollection RegisterModuleConfiguration(this IServiceCollection services, IConfiguration configuration) where TModuleConfiguration : class, IModuleConfiguration, new() + { + services.Configure(configuration.GetSection(nameof(TModuleConfiguration))); + services.AddScoped(sp => + { + TModuleConfiguration sc = new TModuleConfiguration(); + sp.GetRequiredService().GetSection(typeof(TModuleConfiguration).Name).Bind(sc); + return sc; + }); + + return services; + } + + public static IServiceCollection RegisterModuleConfiguration(this IServiceCollection services, IConfiguration configuration) where TModuleConfiguration : class, IModuleConfiguration, new() where TModuleConfigurationValidator : class, IValidateOptions + { + services.Configure(configuration.GetSection(nameof(TModuleConfiguration))); + services.AddScoped(sp => + { + TModuleConfiguration sc = new TModuleConfiguration(); + sp.GetRequiredService().GetSection(typeof(TModuleConfiguration).Name).Bind(sc); + return sc; + }); + + services.AddSingleton, TModuleConfigurationValidator>(); + + return services; + } + } +} diff --git a/Source/Shared/Features/Modules/ModuleRegistrator.cs b/Source/Shared/Features/Modules/Registrator.cs similarity index 97% rename from Source/Shared/Features/Modules/ModuleRegistrator.cs rename to Source/Shared/Features/Modules/Registrator.cs index 346e4fc0..ac21e568 100644 --- a/Source/Shared/Features/Modules/ModuleRegistrator.cs +++ b/Source/Shared/Features/Modules/Registrator.cs @@ -7,7 +7,7 @@ namespace Shared.Features.Modules { - public static class ModuleRegistrator + public static class Registrator { public static IServiceCollection AddModule(this IServiceCollection services, IConfiguration configuration) where TStartup : IModuleStartup, new() diff --git a/Source/Shared/Features/Server/AuthenticatedBaseController.cs b/Source/Shared/Features/Server/BaseController.cs similarity index 84% rename from Source/Shared/Features/Server/AuthenticatedBaseController.cs rename to Source/Shared/Features/Server/BaseController.cs index 28907b1b..b6a713af 100644 --- a/Source/Shared/Features/Server/AuthenticatedBaseController.cs +++ b/Source/Shared/Features/Server/BaseController.cs @@ -3,7 +3,7 @@ using Shared.Features.CQRS.Command; using Shared.Features.CQRS.Query; using Shared.Kernel.BuildingBlocks; -using Shared.Kernel.BuildingBlocks.ModelValidation; +using Shared.Kernel.BuildingBlocks.Services.ModelValidation; using SharedKernel.Interfaces; namespace Shared.Features.Server @@ -13,7 +13,7 @@ public class BaseController : ControllerBase protected readonly ICommandDispatcher commandDispatcher; protected readonly IQueryDispatcher queryDispatcher; protected readonly IExecutionContextAccessor executionContextAccessor; - protected readonly IWebContextAccessor webContextAccessor; + protected readonly IExecutionContext webContextAccessor; protected readonly IValidationService validationService; public BaseController(IServiceProvider serviceProvider) @@ -21,7 +21,7 @@ public BaseController(IServiceProvider serviceProvider) commandDispatcher = serviceProvider.GetRequiredService(); queryDispatcher = serviceProvider.GetRequiredService(); executionContextAccessor = serviceProvider.GetRequiredService(); - webContextAccessor = serviceProvider.GetService(); + webContextAccessor = serviceProvider.GetService(); validationService = serviceProvider.GetRequiredService(); } diff --git a/Source/Shared/Features/Server/ExecutionContext/Registrator.cs b/Source/Shared/Features/Server/ExecutionContext/Registrator.cs new file mode 100644 index 00000000..383c1a0c --- /dev/null +++ b/Source/Shared/Features/Server/ExecutionContext/Registrator.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Shared.Kernel.BuildingBlocks; + +namespace Shared.Features.Server.ExecutionContext +{ + public static class Registrator + { + public static IServiceCollection AddServerExecutionContext(this IServiceCollection services) + { + services.AddHttpContextAccessor(); + services.AddScoped(); + services.AddScoped(ServerExecutionContext.CreateInstance); + return services; + } + + public static IApplicationBuilder UseServerExecutionContextMiddleware(this IApplicationBuilder app) + { + app.UseMiddleware(); + + return app; + } + } +} diff --git a/Source/Shared/Features/Server/ExecutionContext/ServerExecutionContext.cs b/Source/Shared/Features/Server/ExecutionContext/ServerExecutionContext.cs new file mode 100644 index 00000000..edc88d45 --- /dev/null +++ b/Source/Shared/Features/Server/ExecutionContext/ServerExecutionContext.cs @@ -0,0 +1,58 @@ +using Microsoft.AspNetCore.Hosting.Server; +using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Shared.Kernel.BuildingBlocks; +using Shared.Kernel.BuildingBlocks.Auth; +using Shared.Kernel.BuildingBlocks.Auth.DomainKernel; +using Shared.Kernel.Extensions.ClaimsPrincipal; + +namespace Shared.Features.Server.ExecutionContext +{ + public class ServerExecutionContext : IExecutionContext + { + private static ServerExecutionContext executionContext; + private ServerExecutionContext() { } + + public bool AuthenticatedRequest { get; private set; } + public Guid UserId { get; private set; } + public Guid TenantId { get; private set; } + public SubscriptionPlanType TenantPlan { get; private set; } + public TenantRole TenantRole { get; private set; } + public IHostEnvironment HostingEnvironment { get; set; } + public Uri BaseURI { get; private set; } + + public static ServerExecutionContext CreateInstance(IServiceProvider serviceProvider) + { + if (executionContext is not null) + { + return executionContext; + } + + return new ServerExecutionContext() + { + HostingEnvironment = serviceProvider.GetRequiredService() + }; + } + + public void InitializeInstance(HttpContext httpContext) + { + var server = httpContext.RequestServices.GetRequiredService(); + var addresses = server?.Features.Get(); + + BaseURI = new Uri(addresses?.Addresses.FirstOrDefault(a => a.Contains("https")) ?? string.Empty); + + if (httpContext.User.Identity.IsAuthenticated is false) + { + AuthenticatedRequest = false; + return; + } + + UserId = httpContext.User.GetUserId(); + TenantId = httpContext.User.GetTenantId(); + TenantPlan = httpContext.User.GetTenantSubscriptionPlanType(); + TenantRole = httpContext.User.GetTenantRole(); + } + } +} diff --git a/Source/Shared/Features/Server/ExecutionContext/ServerExecutionContextMiddleware.cs b/Source/Shared/Features/Server/ExecutionContext/ServerExecutionContextMiddleware.cs new file mode 100644 index 00000000..b6f3811c --- /dev/null +++ b/Source/Shared/Features/Server/ExecutionContext/ServerExecutionContextMiddleware.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Shared.Kernel.BuildingBlocks; + +namespace Shared.Features.Server.ExecutionContext +{ + public class ServerExecutionContextMiddleware : IMiddleware + { + public async Task InvokeAsync(HttpContext context, RequestDelegate next) + { + var executionContext = (ServerExecutionContext)context.RequestServices.GetService(); + executionContext.InitializeInstance(context); + + await next(context); + } + } +} diff --git a/Source/Shared/Features/Server/ServerExecutionBase.cs b/Source/Shared/Features/Server/ServerExecutionBase.cs new file mode 100644 index 00000000..dc9abf69 --- /dev/null +++ b/Source/Shared/Features/Server/ServerExecutionBase.cs @@ -0,0 +1,30 @@ +using Microsoft.Extensions.DependencyInjection; +using Shared.Features.CQRS.Command; +using Shared.Features.CQRS.DomainEvent; +using Shared.Features.CQRS.IntegrationEvent; +using Shared.Features.CQRS.Query; +using Shared.Kernel.BuildingBlocks; +using Shared.Kernel.BuildingBlocks.Services.ModelValidation; + +namespace Shared.Features.Server +{ + public class ServerExecutionBase + { + protected readonly IExecutionContext executionContext; + protected readonly ICommandDispatcher commandDispatcher; + protected readonly IQueryDispatcher queryDispatcher; + protected readonly IIntegrationEventDispatcher integrationEventDispatcher; + protected readonly IDomainEventDispatcher domainEventDispatcher; + protected readonly IValidationService validationService; + + public ServerExecutionBase(IServiceProvider serviceProvider) + { + executionContext = serviceProvider.GetRequiredService(); + commandDispatcher = serviceProvider.GetRequiredService(); + queryDispatcher = serviceProvider.GetRequiredService(); + integrationEventDispatcher = serviceProvider.GetRequiredService(); + domainEventDispatcher = serviceProvider.GetRequiredService(); + validationService = serviceProvider.GetRequiredService(); + } + } +} diff --git a/Source/Shared/Features/Shared.Features.csproj b/Source/Shared/Features/Shared.Features.csproj index a8628696..b244c07e 100644 --- a/Source/Shared/Features/Shared.Features.csproj +++ b/Source/Shared/Features/Shared.Features.csproj @@ -1,20 +1,19 @@  - net6.0 + net8.0 enable enable false - - - - - + + + + diff --git a/Source/Shared/Kernel/BuildingBlocks/Auth/AuthorizationDIRegistrator.cs b/Source/Shared/Kernel/BuildingBlocks/Auth/AuthorizationDIRegistrator.cs index 10024f2d..83d5bd09 100644 --- a/Source/Shared/Kernel/BuildingBlocks/Auth/AuthorizationDIRegistrator.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Auth/AuthorizationDIRegistrator.cs @@ -1,7 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Authorization; -using Shared.SharedKernel.Constants; -using Shared.Kernel.Constants; +using Shared.Kernel.BuildingBlocks.Auth.Constants; namespace Shared.Kernel.BuildingBlocks.Authorization { diff --git a/Source/Shared/Kernel/Constants/ClaimConstants.cs b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/ClaimConstants.cs similarity index 91% rename from Source/Shared/Kernel/Constants/ClaimConstants.cs rename to Source/Shared/Kernel/BuildingBlocks/Auth/Constants/ClaimConstants.cs index cf5e0279..f08f5e85 100644 --- a/Source/Shared/Kernel/Constants/ClaimConstants.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/ClaimConstants.cs @@ -1,6 +1,6 @@ using System.Security.Claims; -namespace Shared.SharedKernel.Constants +namespace Shared.Kernel.BuildingBlocks.Auth.Constants { public class ClaimConstants { diff --git a/Source/Shared/Kernel/Constants/PolicyConstants.cs b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/PolicyConstants.cs similarity index 89% rename from Source/Shared/Kernel/Constants/PolicyConstants.cs rename to Source/Shared/Kernel/BuildingBlocks/Auth/Constants/PolicyConstants.cs index d450ef74..3fcaddff 100644 --- a/Source/Shared/Kernel/Constants/PolicyConstants.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/PolicyConstants.cs @@ -1,4 +1,4 @@ -namespace Shared.Kernel.Constants +namespace Shared.Kernel.BuildingBlocks.Auth.Constants { public class PolicyConstants { diff --git a/Source/Shared/Kernel/Constants/SubscriptionPlanConstants.cs b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/SubscriptionPlanConstants.cs similarity index 80% rename from Source/Shared/Kernel/Constants/SubscriptionPlanConstants.cs rename to Source/Shared/Kernel/BuildingBlocks/Auth/Constants/SubscriptionPlanConstants.cs index d4c5344d..519dc855 100644 --- a/Source/Shared/Kernel/Constants/SubscriptionPlanConstants.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/SubscriptionPlanConstants.cs @@ -1,4 +1,4 @@ -namespace Shared.SharedKernel.Constants +namespace Shared.Kernel.BuildingBlocks.Auth.Constants { public class SubscriptionPlanConstants { diff --git a/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/TenantRoleConstants.cs b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/TenantRoleConstants.cs new file mode 100644 index 00000000..119a7ad3 --- /dev/null +++ b/Source/Shared/Kernel/BuildingBlocks/Auth/Constants/TenantRoleConstants.cs @@ -0,0 +1,8 @@ +namespace Shared.Kernel.BuildingBlocks.Auth.Constants +{ + public class TenantRoleConstants + { + public const string User = nameof(User); + public const string Admin = nameof(Admin); + } +} diff --git a/Source/Shared/Kernel/BuildingBlocks/Auth/CreatorPolicyHandler.cs b/Source/Shared/Kernel/BuildingBlocks/Auth/CreatorPolicyHandler.cs index c2f7cdb1..5848c9c6 100644 --- a/Source/Shared/Kernel/BuildingBlocks/Auth/CreatorPolicyHandler.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Auth/CreatorPolicyHandler.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Authorization; +using Shared.Kernel.Extensions.ClaimsPrincipal; using Shared.SharedKernel.Exstensions; using Shared.SharedKernel.Interfaces; diff --git a/Source/Shared/Kernel/BuildingBlocks/IExecutionContext.cs b/Source/Shared/Kernel/BuildingBlocks/IExecutionContext.cs new file mode 100644 index 00000000..8dacb2c1 --- /dev/null +++ b/Source/Shared/Kernel/BuildingBlocks/IExecutionContext.cs @@ -0,0 +1,22 @@ +using Shared.Kernel.BuildingBlocks.Auth.DomainKernel; +using Microsoft.Extensions.Hosting; + +namespace Shared.Kernel.BuildingBlocks +{ + public interface IExecutionContext + { + Guid UserId { get; } + + Guid TenantId { get; } + + SubscriptionPlanType TenantPlan { get; } + + TenantRole TenantRole { get; } + + public Uri BaseURI { get; } + + bool AuthenticatedRequest { get; } + + IHostEnvironment HostingEnvironment { get; } + } +} diff --git a/Source/Shared/Kernel/BuildingBlocks/IIntegrationEvent.cs b/Source/Shared/Kernel/BuildingBlocks/IIntegrationEvent.cs new file mode 100644 index 00000000..b30a15b4 --- /dev/null +++ b/Source/Shared/Kernel/BuildingBlocks/IIntegrationEvent.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.Kernel.BuildingBlocks +{ + public class IIntegrationEvent + { + } +} diff --git a/Source/Shared/Kernel/BuildingBlocks/IWebContextAccessor.cs b/Source/Shared/Kernel/BuildingBlocks/IWebContextAccessor.cs deleted file mode 100644 index 1d4b38c2..00000000 --- a/Source/Shared/Kernel/BuildingBlocks/IWebContextAccessor.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Shared.Kernel.BuildingBlocks -{ - public interface IWebContextAccessor - { - public Uri BaseURI { get; set; } - } -} diff --git a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/Excceptions/NoValidatorFoundException.cs b/Source/Shared/Kernel/BuildingBlocks/ModelValidation/Excceptions/NoValidatorFoundException.cs deleted file mode 100644 index 2d09cbfe..00000000 --- a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/Excceptions/NoValidatorFoundException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Shared.Kernel.BuildingBlocks.ModelValidation.Excceptions -{ - public class NoValidatorFoundException : Exception - { - } -} diff --git a/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/Excceptions/NoValidatorFoundException.cs b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/Excceptions/NoValidatorFoundException.cs new file mode 100644 index 00000000..61e075d7 --- /dev/null +++ b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/Excceptions/NoValidatorFoundException.cs @@ -0,0 +1,6 @@ +namespace Shared.Kernel.BuildingBlocks.Services.ModelValidation.Excceptions +{ + public class NoValidatorFoundException : Exception + { + } +} diff --git a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/IValidationService.cs b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/IValidationService.cs similarity index 57% rename from Source/Shared/Kernel/BuildingBlocks/ModelValidation/IValidationService.cs rename to Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/IValidationService.cs index 296ebabe..d5118d1a 100644 --- a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/IValidationService.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/IValidationService.cs @@ -1,4 +1,4 @@ -namespace Shared.Kernel.BuildingBlocks.ModelValidation +namespace Shared.Kernel.BuildingBlocks.Services.ModelValidation { public interface IValidationService { diff --git a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/Registrator.cs b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/Registrator.cs similarity index 82% rename from Source/Shared/Kernel/BuildingBlocks/ModelValidation/Registrator.cs rename to Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/Registrator.cs index ee15114c..a013fe68 100644 --- a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/Registrator.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/Registrator.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -namespace Shared.Kernel.BuildingBlocks.ModelValidation +namespace Shared.Kernel.BuildingBlocks.Services.ModelValidation { public static class Registrator { diff --git a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/ValidationService.cs b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/ValidationService.cs similarity index 92% rename from Source/Shared/Kernel/BuildingBlocks/ModelValidation/ValidationService.cs rename to Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/ValidationService.cs index 1f035b22..c754baf5 100644 --- a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/ValidationService.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/ValidationService.cs @@ -1,10 +1,10 @@ using FluentValidation; using FluentValidation.Results; using Microsoft.Extensions.DependencyInjection; -using Shared.Kernel.BuildingBlocks.ModelValidation.Excceptions; +using Shared.Kernel.BuildingBlocks.Services.ModelValidation.Excceptions; using static FluentValidation.AssemblyScanner; -namespace Shared.Kernel.BuildingBlocks.ModelValidation +namespace Shared.Kernel.BuildingBlocks.Services.ModelValidation { public class ValidationService : IValidationService { diff --git a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/ValidationServiceResult.cs b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/ValidationServiceResult.cs similarity index 68% rename from Source/Shared/Kernel/BuildingBlocks/ModelValidation/ValidationServiceResult.cs rename to Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/ValidationServiceResult.cs index f3e35b55..abdbc81b 100644 --- a/Source/Shared/Kernel/BuildingBlocks/ModelValidation/ValidationServiceResult.cs +++ b/Source/Shared/Kernel/BuildingBlocks/Services/ModelValidation/ValidationServiceResult.cs @@ -1,4 +1,4 @@ -namespace Shared.Kernel.BuildingBlocks.ModelValidation +namespace Shared.Kernel.BuildingBlocks.Services.ModelValidation { public class ValidationServiceResult { diff --git a/Source/Shared/Kernel/Components/BaseComponent.cs b/Source/Shared/Kernel/Components/BaseComponent.cs deleted file mode 100644 index 07a4c5dd..00000000 --- a/Source/Shared/Kernel/Components/BaseComponent.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.JSInterop; -using Shared.Kernel.BuildingBlocks.Services; -using System.Security.Claims; - -namespace Shared.Web.Client -{ - public class BaseComponent : ComponentBase - { - [Inject] public HttpClientService HttpClientService { get; set; } - [Inject] public ValidationService ValidationService { get; set; } - [Inject] public IJSRuntime JSRuntime { get; set; } - [Inject] public NavigationManager NavigationManager { get; set; } - [CascadingParameter] public ClaimsPrincipal User { get; set; } - [CascadingParameter] public string TenantName { get; set; } - } -} diff --git a/Source/Shared/Kernel/Constants/EndpointConstants.cs b/Source/Shared/Kernel/Constants/EndpointConstants.cs deleted file mode 100644 index 822b6653..00000000 --- a/Source/Shared/Kernel/Constants/EndpointConstants.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Shared.SharedKernel.Constants -{ - public class EndpointConstants - { - public const string IdentityAccountPath = "/Identity/Account"; - public const string SignUpPath = "Identity/SignUp"; - public const string LoginPath = "Identity/Login"; - public const string LogoutPath = "api/user/Logout"; - public const string UserClaimsPath = "api/user"; - public const string StripePremiumSubscriptionPath = "/api/stripe/subscribe/premium"; - public const string StripeEnterpriseSubscriptionPath = "/api/stripe/subscribe/enterprise"; - } -} diff --git a/Source/Shared/Kernel/Constants/Modules/SubscriptionsEndpointConstants.cs b/Source/Shared/Kernel/Constants/Modules/SubscriptionsEndpointConstants.cs new file mode 100644 index 00000000..3a664fef --- /dev/null +++ b/Source/Shared/Kernel/Constants/Modules/SubscriptionsEndpointConstants.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.Kernel.Constants.Modules +{ + public partial class EndpointConstants + { + public static class Subscriptions + { + public const string StripePremiumSubscriptionPath = "/api/stripe/subscribe/premium"; + public const string StripeEnterpriseSubscriptionPath = "/api/stripe/subscribe/enterprise"; + } + } +} diff --git a/Source/Shared/Kernel/Constants/Modules/TenantIdentityEndpointContants.cs b/Source/Shared/Kernel/Constants/Modules/TenantIdentityEndpointContants.cs new file mode 100644 index 00000000..88fd1dbd --- /dev/null +++ b/Source/Shared/Kernel/Constants/Modules/TenantIdentityEndpointContants.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.Kernel.Constants.Modules +{ + public partial class EndpointConstants + { + public static class TenantIdentity + { + public const string IdentityAccountPath = "/Identity/Account"; + public const string SignUpPath = "Identity/SignUp"; + public const string LoginPath = "Identity/Login"; + public const string LogoutPath = "api/user/Logout"; + public const string UserClaimsPath = "api/user"; + } + } +} diff --git a/Source/Shared/Kernel/Constants/SignalRConstants.cs b/Source/Shared/Kernel/Constants/SignalRConstants.cs deleted file mode 100644 index 70d7dee4..00000000 --- a/Source/Shared/Kernel/Constants/SignalRConstants.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Shared.SharedKernel.Constants -{ - public class SignalRConstants - { - public const string NotificationEndpoint = "/NotificationHub"; - } -} diff --git a/Source/Shared/Kernel/Constants/TenantRoleConstants.cs b/Source/Shared/Kernel/Constants/TenantRoleConstants.cs deleted file mode 100644 index 5a0f128f..00000000 --- a/Source/Shared/Kernel/Constants/TenantRoleConstants.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Shared.SharedKernel.Constants -{ - public class TenantRoleConstants - { - public const string User = nameof(User); - public const string Admin = nameof(Admin); - } -} diff --git a/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/ClaimNotFoundException.cs b/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/ClaimNotFoundException.cs deleted file mode 100644 index 29d05ce0..00000000 --- a/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/ClaimNotFoundException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Shared.SharedKernel.Exceptions.Extensions.ClaimsPrincipal -{ - public class ClaimNotFoundException : Exception - { - } -} diff --git a/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/NoRoleClaimException.cs b/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/NoRoleClaimException.cs deleted file mode 100644 index b16f1b99..00000000 --- a/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/NoRoleClaimException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Shared.SharedKernel.Exceptions.Extensions.ClaimsPrincipal -{ - public class NoRoleClaimException : Exception - { - } -} diff --git a/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/UserIdClaimNotFoundException.cs b/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/UserIdClaimNotFoundException.cs deleted file mode 100644 index 7a7c67ca..00000000 --- a/Source/Shared/Kernel/Exceptions/Extensions/ClaimsPrincipal/UserIdClaimNotFoundException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Shared.SharedKernel.Exceptions.Extensions.ClaimsPrincipal -{ - internal class UserIdClaimNotFoundException - { - } -} diff --git a/Source/Shared/Kernel/Extensions/ClaimsPrincipal/ClaimsPrincipalExtensions.cs b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/ClaimsPrincipalExtensions.cs new file mode 100644 index 00000000..fb8dc324 --- /dev/null +++ b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/ClaimsPrincipalExtensions.cs @@ -0,0 +1,60 @@ +using Shared.Kernel.BuildingBlocks.Auth; +using Shared.Kernel.BuildingBlocks.Auth.Constants; +using Shared.Kernel.BuildingBlocks.Auth.DomainKernel; +using Shared.Kernel.Extensions.ClaimsPrincipal.Exceptions; +using System.ComponentModel; + +namespace Shared.Kernel.Extensions.ClaimsPrincipal +{ + public static class ClaimsPrincipalExtensions + { + public static bool HasUserIdClaim(this System.Security.Claims.ClaimsPrincipal claimsPrincipal) + { + return claimsPrincipal.HasClaim(c => c.Type == ClaimConstants.UserIdClaimType); + } + + public static T GetUserId(this System.Security.Claims.ClaimsPrincipal claimsPrincipal) + { + TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); + return (T)converter.ConvertFrom(claimsPrincipal?.FindFirst(ClaimConstants.UserIdClaimType).Value); + } + + public static bool HasTenantIdClaim(this System.Security.Claims.ClaimsPrincipal claimsPrincipal) + { + return claimsPrincipal.HasClaim(c => c.Type == ClaimConstants.TenantIdClaimType); + } + + public static T GetTenantId(this System.Security.Claims.ClaimsPrincipal claimsPrincipal) + { + TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); + return (T)converter.ConvertFrom(claimsPrincipal?.FindFirst(ClaimConstants.TenantPlanClaimType).Value); + } + + public static TenantRole GetTenantRole(this System.Security.Claims.ClaimsPrincipal claimsPrincipal) + { + return (TenantRole)Enum.Parse(typeof(TenantRole), claimsPrincipal?.FindFirst(ClaimConstants.UserRoleInTenantClaimType).Value); + } + + public static SubscriptionPlanType GetTenantSubscriptionPlanType(this System.Security.Claims.ClaimsPrincipal claimsPrincipal) + { + return (SubscriptionPlanType)Enum.Parse(typeof(SubscriptionPlanType), claimsPrincipal?.FindFirst(ClaimConstants.TenantPlanClaimType).Value); + } + + public static string GetRoleClaim(this System.Security.Claims.ClaimsPrincipal claimsPrincipal) + { + return claimsPrincipal.GetClaimValue(ClaimConstants.UserRoleInTenantClaimType); + } + + public static string GetClaimValue(this System.Security.Claims.ClaimsPrincipal claimsPrincipal, string claimType) + { + try + { + return claimsPrincipal.FindFirst(claimType)?.Value; + } + catch (Exception _) + { + throw new ClaimNotFoundException(); + } + } + } +} diff --git a/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/ClaimNotFoundException.cs b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/ClaimNotFoundException.cs new file mode 100644 index 00000000..1153b7d9 --- /dev/null +++ b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/ClaimNotFoundException.cs @@ -0,0 +1,6 @@ +namespace Shared.Kernel.Extensions.ClaimsPrincipal.Exceptions +{ + public class ClaimNotFoundException : Exception + { + } +} diff --git a/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/NoRoleClaimException.cs b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/NoRoleClaimException.cs new file mode 100644 index 00000000..71158985 --- /dev/null +++ b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/NoRoleClaimException.cs @@ -0,0 +1,6 @@ +namespace Shared.Kernel.Extensions.ClaimsPrincipal.Exceptions +{ + public class NoRoleClaimException : Exception + { + } +} diff --git a/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/UserIdClaimNotFoundException.cs b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/UserIdClaimNotFoundException.cs new file mode 100644 index 00000000..d72be29c --- /dev/null +++ b/Source/Shared/Kernel/Extensions/ClaimsPrincipal/Exceptions/UserIdClaimNotFoundException.cs @@ -0,0 +1,6 @@ +namespace Shared.Kernel.Extensions.ClaimsPrincipal.Exceptions +{ + internal class UserIdClaimNotFoundException + { + } +} diff --git a/Source/Shared/Kernel/Extensions/ClaimsPrincipalExtensions.cs b/Source/Shared/Kernel/Extensions/ClaimsPrincipalExtensions.cs deleted file mode 100644 index 7f417e0d..00000000 --- a/Source/Shared/Kernel/Extensions/ClaimsPrincipalExtensions.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Shared.SharedKernel.Constants; -using Shared.SharedKernel.Exceptions.Extensions.ClaimsPrincipal; -using System.ComponentModel; -using System.Security.Claims; - -namespace Shared.SharedKernel.Exstensions -{ - public static class ClaimsPrincipalExtensions - { - public static bool HasUserIdClaim(this ClaimsPrincipal claimsPrincipal) - { - return claimsPrincipal.HasClaim(c => c.Type == ClaimConstants.UserIdClaimType); - } - - public static T GetUserId(this ClaimsPrincipal claimsPrincipal) - { - TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); - return (T)converter.ConvertFrom(claimsPrincipal?.FindFirst(ClaimConstants.UserIdClaimType).Value); - } - - public static bool HasTenantIdClaim(this ClaimsPrincipal claimsPrincipal) - { - return claimsPrincipal.HasClaim(c => c.Type == ClaimConstants.TenantIdClaimType); - } - - public static T GetTenantId(this ClaimsPrincipal claimsPrincipal) - { - TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); - return (T)converter.ConvertFrom(claimsPrincipal?.FindFirst(ClaimConstants.TenantPlanClaimType).Value); - } - - public static string GetRoleClaim(this ClaimsPrincipal claimsPrincipal) - { - return claimsPrincipal.GetClaimValue(ClaimConstants.UserRoleInTenantClaimType); - } - - public static string GetClaimValue(this ClaimsPrincipal claimsPrincipal, string claimType) - { - try - { - return claimsPrincipal.FindFirst(claimType)?.Value; - } - catch(Exception _) - { - throw new ClaimNotFoundException(); - } - } - } -} diff --git a/Source/Shared/Kernel/Shared.Kernel.csproj b/Source/Shared/Kernel/Shared.Kernel.csproj index e765605c..dfedea92 100644 --- a/Source/Shared/Kernel/Shared.Kernel.csproj +++ b/Source/Shared/Kernel/Shared.Kernel.csproj @@ -1,19 +1,17 @@  - net6.0 + net8.0 - + - - + + - - diff --git a/Source/Web/WebServer/BuildingBlocks/APIVersioning/APIVersioningMdwRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/APIVersioning/APIVersioningMdwRegistrator.cs deleted file mode 100644 index 0da8acbb..00000000 --- a/Source/Web/WebServer/BuildingBlocks/APIVersioning/APIVersioningMdwRegistrator.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.AspNetCore.Builder; - -namespace Web.Server.BuildingBlocks.Swagger -{ - public static class APIVersioningMdwRegistrator - { - public static IApplicationBuilder RegisterApiVersioning(this IApplicationBuilder applicationBuilder) - { - applicationBuilder.UseApiVersioning(); - - return applicationBuilder; - } - } -} diff --git a/Source/Web/WebServer/BuildingBlocks/APIVersioning/APIVersioningDIRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/APIVersioning/Registrator.cs similarity index 54% rename from Source/Web/WebServer/BuildingBlocks/APIVersioning/APIVersioningDIRegistrator.cs rename to Source/Web/WebServer/BuildingBlocks/APIVersioning/Registrator.cs index c262c7c4..82b5b238 100644 --- a/Source/Web/WebServer/BuildingBlocks/APIVersioning/APIVersioningDIRegistrator.cs +++ b/Source/Web/WebServer/BuildingBlocks/APIVersioning/Registrator.cs @@ -1,12 +1,13 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Versioning; using Microsoft.Extensions.DependencyInjection; namespace Web.Server.BuildingBlocks.Swagger { - public static class APIVersioningDIRegistrator + public static class Registrator { - public static IServiceCollection RegisterApiVersioning(this IServiceCollection serviceCollection) + public static IServiceCollection Add_ApiVersioning(this IServiceCollection serviceCollection) { serviceCollection.AddApiVersioning(options => { @@ -17,5 +18,12 @@ public static IServiceCollection RegisterApiVersioning(this IServiceCollection s return serviceCollection; } + + public static IApplicationBuilder UseApiVersioningMiddleware(this IApplicationBuilder applicationBuilder) + { + applicationBuilder.UseApiVersioning(); + + return applicationBuilder; + } } } diff --git a/Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/AntiforgeryTokenDIRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/AntiforgeryTokenDIRegistrator.cs deleted file mode 100644 index e23a7b4e..00000000 --- a/Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/AntiforgeryTokenDIRegistrator.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; - -namespace WebServer.Modules.ModelValidation -{ - public static class AntiforgeryTokenDIRegistrator - { - public static IServiceCollection RegisterAntiforgeryToken(this IServiceCollection services) - { - return services; - //return services.AddAntiforgery(options => - //{ - // options.HeaderName = "X-XSRF-TOKEN"; - // options.Cookie.Name = "__Host-X-XSRF-TOKEN"; - // options.Cookie.SameSite = SameSiteMode.Strict; - // options.Cookie.SecurePolicy = CookieSecurePolicy.Always; - //}); - } - } -} diff --git a/Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/Registrator.cs b/Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/Registrator.cs new file mode 100644 index 00000000..11c06035 --- /dev/null +++ b/Source/Web/WebServer/BuildingBlocks/AntiforgeryToken/Registrator.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace WebServer.Modules.ModelValidation +{ + public static class Registrator + { + public static IServiceCollection AddAntiforgeryToken(this IServiceCollection services) + { + return services.AddAntiforgery(options => + { + options.HeaderName = "X-XSRF-TOKEN"; + options.Cookie.Name = "__Host-X-XSRF-TOKEN"; + options.Cookie.SameSite = SameSiteMode.Strict; + options.Cookie.SecurePolicy = CookieSecurePolicy.Always; + }); + } + } +} diff --git a/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs b/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs index cc96e359..5026c977 100644 --- a/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs +++ b/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessor.cs @@ -7,7 +7,7 @@ namespace Web.Server.BuildingBlocks.ContextAccessor.WebContextAccessor { - public class WebContextAccessor : IWebContextAccessor + public class WebContextAccessor : IExecutionContext { public Uri BaseURI { get; set; } public WebContextAccessor(IServiceProvider serviceProvider) diff --git a/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs index 32c19b4d..2717a914 100644 --- a/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs +++ b/Source/Web/WebServer/BuildingBlocks/ContextAccessor/WebContextAccessor/WebContextAccessorDIRegistrator.cs @@ -7,7 +7,7 @@ public static class WebContextAccessorDIRegistrator { public static IServiceCollection RegisterWebContextAccessor(this IServiceCollection serviceCollection) { - return serviceCollection.AddSingleton(); + return serviceCollection.AddSingleton(); } } } diff --git a/Source/Web/WebServer/BuildingBlocks/ExceptionHandling/ExceptionHandlingMdwRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/ExceptionHandling/Registrator.cs similarity index 55% rename from Source/Web/WebServer/BuildingBlocks/ExceptionHandling/ExceptionHandlingMdwRegistrator.cs rename to Source/Web/WebServer/BuildingBlocks/ExceptionHandling/Registrator.cs index defc9d30..ad92ef16 100644 --- a/Source/Web/WebServer/BuildingBlocks/ExceptionHandling/ExceptionHandlingMdwRegistrator.cs +++ b/Source/Web/WebServer/BuildingBlocks/ExceptionHandling/Registrator.cs @@ -2,9 +2,9 @@ namespace Web.Server.BuildingBlocks.HostingInformation { - public static class ExceptionHandlingMdwRegistrator + public static class Registrator { - public static IApplicationBuilder RegisterExceptionHandling(this IApplicationBuilder applicationBuilder) + public static IApplicationBuilder UseExceptionHandlingMiddleware(this IApplicationBuilder applicationBuilder) { return applicationBuilder.UseExceptionHandler("/exceptionHandler"); } diff --git a/Source/Web/WebServer/BuildingBlocks/Logging/LoggingDIRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/Logging/LoggingDIRegistrator.cs deleted file mode 100644 index c524cb16..00000000 --- a/Source/Web/WebServer/BuildingBlocks/Logging/LoggingDIRegistrator.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; - -namespace Web.Server.BuildingBlocks.Logging -{ - public static class LoggingDIRegistrator - { - public static IServiceCollection RegisterLogging(this IServiceCollection serviceCollection) - { - return serviceCollection.AddHttpLogging(options => - { - }); - } - } -} diff --git a/Source/Web/WebServer/BuildingBlocks/Logging/LoggingMdwRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/Logging/LoggingMdwRegistrator.cs deleted file mode 100644 index 80692435..00000000 --- a/Source/Web/WebServer/BuildingBlocks/Logging/LoggingMdwRegistrator.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Builder; - -namespace Web.Server.BuildingBlocks.Logging -{ - public static class LoggingMdwRegistrator - { - public static IApplicationBuilder RegisterLogging(this IApplicationBuilder application) - { - return application.UseHttpLogging(); - } - } -} diff --git a/Source/Web/WebServer/BuildingBlocks/Logging/Registrator.cs b/Source/Web/WebServer/BuildingBlocks/Logging/Registrator.cs new file mode 100644 index 00000000..ac7c6c42 --- /dev/null +++ b/Source/Web/WebServer/BuildingBlocks/Logging/Registrator.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace Web.Server.BuildingBlocks.Logging +{ + public static class Registrator + { + public static IServiceCollection Add_Logging(this IServiceCollection serviceCollection) + { + return serviceCollection.AddHttpLogging(options => + { + }); + } + + public static IApplicationBuilder UseLoggingMiddleware(this IApplicationBuilder application) + { + return application.UseHttpLogging(); + } + } +} diff --git a/Source/Web/WebServer/BuildingBlocks/ModelValidation/ModelValidationDIRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/ModelValidation/Registrator.cs similarity index 86% rename from Source/Web/WebServer/BuildingBlocks/ModelValidation/ModelValidationDIRegistrator.cs rename to Source/Web/WebServer/BuildingBlocks/ModelValidation/Registrator.cs index 8426a420..7eaf1883 100644 --- a/Source/Web/WebServer/BuildingBlocks/ModelValidation/ModelValidationDIRegistrator.cs +++ b/Source/Web/WebServer/BuildingBlocks/ModelValidation/Registrator.cs @@ -1,12 +1,13 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; +using Shared.Kernel.BuildingBlocks.Services.ModelValidation; namespace Web.Server.BuildingBlocks.ModelValidation { - public static class ModelValidationDIRegistrator + public static class Registrator { - public static IServiceCollection RegisterModelValidation(this IServiceCollection services) + public static IServiceCollection AddModelValidation(this IServiceCollection services) { services.RegisterModelValidationService(); diff --git a/Source/Web/WebServer/BuildingBlocks/Registrator.cs b/Source/Web/WebServer/BuildingBlocks/Registrator.cs index d2a1c360..2a00ced8 100644 --- a/Source/Web/WebServer/BuildingBlocks/Registrator.cs +++ b/Source/Web/WebServer/BuildingBlocks/Registrator.cs @@ -6,9 +6,9 @@ using Web.Server.BuildingBlocks.Logging; using Web.Server.BuildingBlocks.ModelValidation; using Web.Server.BuildingBlocks.ResponseCompression; +using Web.Server.BuildingBlocks.SecurityHeaders; using Web.Server.BuildingBlocks.Swagger; using WebServer.Modules.ModelValidation; -using WebServer.Modules.Swagger; namespace Web.Server.BuildingBlocks { @@ -16,28 +16,22 @@ public static class Registrator { public static IServiceCollection AddBuildingBlocks(this IServiceCollection services) { - services.RegisterAntiforgeryToken(); - services.RegisterApiVersioning(); - services.RegisterLogging(); - services.RegisterModelValidation(); - services.RegisterSwagger(); - services.RegisterWebContextAccessor(); - services.RegisterExecutionContextAccessor(); - services.RegisterModelValidation(); - services.RegisterResponseCompression(); + services.AddAntiforgeryToken(); + services.Add_ApiVersioning(); + services.Add_Logging(); + services.AddModelValidation(); + services.AddSwagger(); return services; } - public static IApplicationBuilder UseBuildingBlocks(this IApplicationBuilder applicationBuilder) + public static IApplicationBuilder UseBuildingBlocksMiddleware(this IApplicationBuilder applicationBuilder) { - applicationBuilder.RegisterApiVersioning(); - applicationBuilder.RegisterExceptionHandling(); - applicationBuilder.RegisterLogging(); - applicationBuilder.RegisterSecurityHeaders(); - applicationBuilder.RegisterSwagger(); - applicationBuilder.RegisterExecutionContextAccessingMiddleware(); - applicationBuilder.UserResponseCompression(); + applicationBuilder.UseApiVersioningMiddleware(); + applicationBuilder.UseExceptionHandlingMiddleware(); + applicationBuilder.UseLoggingMiddleware(); + applicationBuilder.UseSecurityHeadersMiddleware(); + applicationBuilder.UseSwaggerMiddleware(); return applicationBuilder; } diff --git a/Source/Web/WebServer/BuildingBlocks/SecurityHeaders/SecurityHeadersMdwRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/SecurityHeaders/Registrator.cs similarity index 79% rename from Source/Web/WebServer/BuildingBlocks/SecurityHeaders/SecurityHeadersMdwRegistrator.cs rename to Source/Web/WebServer/BuildingBlocks/SecurityHeaders/Registrator.cs index 1c25fe7c..a09a5ee9 100644 --- a/Source/Web/WebServer/BuildingBlocks/SecurityHeaders/SecurityHeadersMdwRegistrator.cs +++ b/Source/Web/WebServer/BuildingBlocks/SecurityHeaders/Registrator.cs @@ -1,14 +1,15 @@ using Microsoft.AspNetCore.Builder; -namespace Web.Server.BuildingBlocks.ModelValidation +namespace Web.Server.BuildingBlocks.SecurityHeaders { - public static class SecurityHeadersMdwRegistrator + public static class Registrator { - public static IApplicationBuilder RegisterSecurityHeaders(this IApplicationBuilder applicationBuilder) + public static IApplicationBuilder UseSecurityHeadersMiddleware(this IApplicationBuilder applicationBuilder) { return applicationBuilder.Use((context, next) => { context.Response.Headers.Remove("X-Powered-By"); + context.Response.Headers.Add("X-Xss-Protection", "1"); context.Response.Headers.Add("X-Frame-Options", "DENY"); context.Response.Headers.Add("Referrer-Policy", "no-referrer"); context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); diff --git a/Source/Web/WebServer/BuildingBlocks/Swagger/SwaggerDIRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/Swagger/Registrator.cs similarity index 62% rename from Source/Web/WebServer/BuildingBlocks/Swagger/SwaggerDIRegistrator.cs rename to Source/Web/WebServer/BuildingBlocks/Swagger/Registrator.cs index f753d40f..6e3590e1 100644 --- a/Source/Web/WebServer/BuildingBlocks/Swagger/SwaggerDIRegistrator.cs +++ b/Source/Web/WebServer/BuildingBlocks/Swagger/Registrator.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; using System; @@ -6,7 +7,7 @@ namespace Web.Server.BuildingBlocks.Swagger { public static class SwaggerDIDIRegistrator { - public static IServiceCollection RegisterSwagger(this IServiceCollection serviceCollection) + public static IServiceCollection AddSwagger(this IServiceCollection serviceCollection) { serviceCollection.AddSwaggerGen(options => { @@ -31,5 +32,17 @@ public static IServiceCollection RegisterSwagger(this IServiceCollection service return serviceCollection; } + + public static IApplicationBuilder UseSwaggerMiddleware(this IApplicationBuilder applicationBuilder) + { + applicationBuilder.UseSwagger(); + applicationBuilder.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); + options.RoutePrefix = "api/swagger/index.html"; + }); + + return applicationBuilder; + } } } diff --git a/Source/Web/WebServer/BuildingBlocks/Swagger/SwaggerMdwRegistrator.cs b/Source/Web/WebServer/BuildingBlocks/Swagger/SwaggerMdwRegistrator.cs deleted file mode 100644 index c6ded6d6..00000000 --- a/Source/Web/WebServer/BuildingBlocks/Swagger/SwaggerMdwRegistrator.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Builder; - -namespace WebServer.Modules.Swagger -{ - public static class SwaggerMdwRegistrator - { - public static IApplicationBuilder RegisterSwagger(this IApplicationBuilder applicationBuilder) - { - applicationBuilder.UseSwagger(); - applicationBuilder.UseSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); - options.RoutePrefix = "api/swagger/index.html"; - }); - - return applicationBuilder; - } - } -} diff --git a/Source/Web/WebServer/Web.Server.csproj b/Source/Web/WebServer/Web.Server.csproj index 8d05bf64..4400f965 100644 --- a/Source/Web/WebServer/Web.Server.csproj +++ b/Source/Web/WebServer/Web.Server.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 f6c6fa58-c628-405d-ba03-853741db9b77 Windows ..\..\.. @@ -58,8 +58,4 @@ - - - - diff --git a/Source/Web/WebWasmClient/Authentication/Antiforgery/AntiForgeryTokenInput.razor b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Antiforgery/AntiForgeryTokenInput.razor similarity index 100% rename from Source/Web/WebWasmClient/Authentication/Antiforgery/AntiForgeryTokenInput.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/Antiforgery/AntiForgeryTokenInput.razor diff --git a/Source/Web/WebWasmClient/Authentication/Antiforgery/AntiforgeryTokenService.cs b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Antiforgery/AntiforgeryTokenService.cs similarity index 79% rename from Source/Web/WebWasmClient/Authentication/Antiforgery/AntiforgeryTokenService.cs rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/Antiforgery/AntiforgeryTokenService.cs index b9fcb1f5..90b2b5be 100644 --- a/Source/Web/WebWasmClient/Authentication/Antiforgery/AntiforgeryTokenService.cs +++ b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Antiforgery/AntiforgeryTokenService.cs @@ -1,13 +1,13 @@ using Microsoft.JSInterop; -namespace WebWasmClient.Authentication.Antiforgery +namespace Web.Client.BuildingBlocks.Authentication.Antiforgery { public class AntiforgeryTokenService { private readonly IJSRuntime jSRuntime; public AntiforgeryTokenService(IJSRuntime jsRuntime) { - this.jSRuntime = jsRuntime; + jSRuntime = jsRuntime; } public async Task GetAntiforgeryTokenAsync() { diff --git a/Source/Web/WebWasmClient/Authentication/AuthorizedHandler.cs b/Source/Web/WebWasmClient/BuildingBlocks/Auth/AuthorizedHandler.cs similarity index 93% rename from Source/Web/WebWasmClient/Authentication/AuthorizedHandler.cs rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/AuthorizedHandler.cs index 1b8a45da..701e98fe 100644 --- a/Source/Web/WebWasmClient/Authentication/AuthorizedHandler.cs +++ b/Source/Web/WebWasmClient/BuildingBlocks/Auth/AuthorizedHandler.cs @@ -1,9 +1,9 @@ using System.Net; using System.Net.Http; using System.Threading; -using WebWasmClient.Authentication.Antiforgery; +using Web.Client.BuildingBlocks.Authentication.Antiforgery; -namespace WebWasmClient.Authentication +namespace Web.Client.BuildingBlocks.Authentication { public class AuthorizedHandler : DelegatingHandler { diff --git a/Source/Web/WebWasmClient/Authentication/Components/LoginDisplayComponent.razor b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/LoginDisplayComponent.razor similarity index 100% rename from Source/Web/WebWasmClient/Authentication/Components/LoginDisplayComponent.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/LoginDisplayComponent.razor diff --git a/Source/Web/WebWasmClient/Authentication/Components/LoginDisplayComponent.razor.css b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/LoginDisplayComponent.razor.css similarity index 100% rename from Source/Web/WebWasmClient/Authentication/Components/LoginDisplayComponent.razor.css rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/LoginDisplayComponent.razor.css diff --git a/Source/Web/WebWasmClient/Authentication/Components/ProfileComponent.razor b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/ProfileComponent.razor similarity index 100% rename from Source/Web/WebWasmClient/Authentication/Components/ProfileComponent.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/ProfileComponent.razor diff --git a/Source/Web/WebWasmClient/Authentication/Components/ProfileComponent.razor.css b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/ProfileComponent.razor.css similarity index 100% rename from Source/Web/WebWasmClient/Authentication/Components/ProfileComponent.razor.css rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/ProfileComponent.razor.css diff --git a/Source/Web/WebWasmClient/Authentication/Components/RedirectToLogin.razor b/Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/RedirectToLogin.razor similarity index 100% rename from Source/Web/WebWasmClient/Authentication/Components/RedirectToLogin.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/Components/RedirectToLogin.razor diff --git a/Source/Web/WebWasmClient/Authentication/HostAuthenticationStateProvider.cs b/Source/Web/WebWasmClient/BuildingBlocks/Auth/HostAuthenticationStateProvider.cs similarity index 94% rename from Source/Web/WebWasmClient/Authentication/HostAuthenticationStateProvider.cs rename to Source/Web/WebWasmClient/BuildingBlocks/Auth/HostAuthenticationStateProvider.cs index 79f96827..e4949830 100644 --- a/Source/Web/WebWasmClient/Authentication/HostAuthenticationStateProvider.cs +++ b/Source/Web/WebWasmClient/BuildingBlocks/Auth/HostAuthenticationStateProvider.cs @@ -4,11 +4,12 @@ using System.Net.Http; using System.Net.Http.Json; using System.Security.Claims; -using WebWasmClient.Authentication.Antiforgery; using Shared.SharedKernel.Constants; using Modules.IdentityModule.Web.DTOs; +using Web.Client.BuildingBlocks.Authentication.Antiforgery; +using Shared.Kernel.BuildingBlocks.Auth.Constants; -namespace WebWasmClient.Authentication +namespace Web.Client.BuildingBlocks.Authentication { public class HostAuthenticationStateProvider : AuthenticationStateProvider { @@ -32,7 +33,7 @@ public override async Task GetAuthenticationStateAsync() private async ValueTask GetUser() { - if (DateTime.Now < (userLastCheck + UserCacheRefreshInterval)) + if (DateTime.Now < userLastCheck + UserCacheRefreshInterval) { return cachedUser; } diff --git a/Source/Web/WebWasmClient/Layouts/BaseLayout.razor b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/BaseLayout.razor similarity index 100% rename from Source/Web/WebWasmClient/Layouts/BaseLayout.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/BaseLayout.razor diff --git a/Source/Web/WebWasmClient/Layouts/BaseLayout.razor.cs b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/BaseLayout.razor.cs similarity index 100% rename from Source/Web/WebWasmClient/Layouts/BaseLayout.razor.cs rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/BaseLayout.razor.cs diff --git a/Source/Web/WebWasmClient/Layouts/BaseLayout.razor.css b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/BaseLayout.razor.css similarity index 100% rename from Source/Web/WebWasmClient/Layouts/BaseLayout.razor.css rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/BaseLayout.razor.css diff --git a/Source/Web/WebWasmClient/Layouts/MainLayout.razor b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayout.razor similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayout.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayout.razor diff --git a/Source/Web/WebWasmClient/Layouts/MainLayout.razor.cs b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayout.razor.cs similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayout.razor.cs rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayout.razor.cs diff --git a/Source/Web/WebWasmClient/Layouts/MainLayout.razor.css b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayout.razor.css similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayout.razor.css rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayout.razor.css diff --git a/Source/Web/WebWasmClient/Layouts/MainLayoutMenu/NavMenu.razor b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/NavMenu.razor similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayoutMenu/NavMenu.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/NavMenu.razor diff --git a/Source/Web/WebWasmClient/Layouts/MainLayoutMenu/NavMenu.razor.css b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/NavMenu.razor.css similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayoutMenu/NavMenu.razor.css rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/NavMenu.razor.css diff --git a/Source/Web/WebWasmClient/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor diff --git a/Source/Web/WebWasmClient/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor.css b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor.css similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor.css rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/SelectedTeamDisplayComp.razor.css diff --git a/Source/Web/WebWasmClient/Layouts/MainLayoutMenu/TeamsOverviewComp.razor b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/TeamsOverviewComp.razor similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayoutMenu/TeamsOverviewComp.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/TeamsOverviewComp.razor diff --git a/Source/Web/WebWasmClient/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.cs b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.cs similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.cs rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.cs diff --git a/Source/Web/WebWasmClient/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.css b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.css similarity index 100% rename from Source/Web/WebWasmClient/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.css rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/MainLayoutMenu/TeamsOverviewComp.razor.css diff --git a/Source/Web/WebWasmClient/Layouts/TopicLayout.razor b/Source/Web/WebWasmClient/BuildingBlocks/Layouts/TopicLayout.razor similarity index 100% rename from Source/Web/WebWasmClient/Layouts/TopicLayout.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Layouts/TopicLayout.razor diff --git a/Source/Web/WebWasmClient/Wrappers/AuthCascadingWrapper.razor b/Source/Web/WebWasmClient/BuildingBlocks/Wrappers/AuthCascadingWrapper.razor similarity index 100% rename from Source/Web/WebWasmClient/Wrappers/AuthCascadingWrapper.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Wrappers/AuthCascadingWrapper.razor diff --git a/Source/Web/WebWasmClient/Wrappers/ExceptionHandlingWrapper.razor b/Source/Web/WebWasmClient/BuildingBlocks/Wrappers/ExceptionHandlingWrapper.razor similarity index 100% rename from Source/Web/WebWasmClient/Wrappers/ExceptionHandlingWrapper.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Wrappers/ExceptionHandlingWrapper.razor diff --git a/Source/Web/WebWasmClient/Wrappers/NotificationWrapper.razor b/Source/Web/WebWasmClient/BuildingBlocks/Wrappers/NotificationWrapper.razor similarity index 100% rename from Source/Web/WebWasmClient/Wrappers/NotificationWrapper.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Wrappers/NotificationWrapper.razor diff --git a/Source/Web/WebWasmClient/Wrappers/SignalRWrapper.razor b/Source/Web/WebWasmClient/BuildingBlocks/Wrappers/SignalRWrapper.razor similarity index 100% rename from Source/Web/WebWasmClient/Wrappers/SignalRWrapper.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Wrappers/SignalRWrapper.razor diff --git a/Source/Web/WebWasmClient/Wrappers/TenantCascadingWrapper.razor b/Source/Web/WebWasmClient/BuildingBlocks/Wrappers/TenantCascadingWrapper.razor similarity index 100% rename from Source/Web/WebWasmClient/Wrappers/TenantCascadingWrapper.razor rename to Source/Web/WebWasmClient/BuildingBlocks/Wrappers/TenantCascadingWrapper.razor diff --git a/Source/Web/WebWasmClient/Program.cs b/Source/Web/WebWasmClient/Program.cs index 565bc034..d4b4d8b8 100644 --- a/Source/Web/WebWasmClient/Program.cs +++ b/Source/Web/WebWasmClient/Program.cs @@ -3,10 +3,10 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using System.Net.Http; -using WebWasmClient.Authentication; -using WebWasmClient.Authentication.Antiforgery; using Blazored.Modal; using Shared.Kernel.BuildingBlocks.Authorization; +using Web.Client.BuildingBlocks.Authentication; +using Web.Client.BuildingBlocks.Authentication.Antiforgery; namespace WebWasmClient { diff --git a/Source/Web/WebWasmClient/Web.Client.csproj b/Source/Web/WebWasmClient/Web.Client.csproj index ef5337c0..7e07c500 100644 --- a/Source/Web/WebWasmClient/Web.Client.csproj +++ b/Source/Web/WebWasmClient/Web.Client.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 true false @@ -45,7 +45,7 @@ - + true diff --git a/Tests/ArchitectureTests/ArchitectureTests.csproj b/Tests/ArchitectureTests/ArchitectureTests.csproj index bdd1ae24..4597195d 100644 --- a/Tests/ArchitectureTests/ArchitectureTests.csproj +++ b/Tests/ArchitectureTests/ArchitectureTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable