From c4798ce33dc70cdef185190cb2c94a007be704f9 Mon Sep 17 00:00:00 2001 From: Oleg Zhuk Date: Fri, 1 Nov 2024 18:08:48 +0200 Subject: [PATCH] VCST-2048: Use ClaimsPrincipalExtensions GetUserId (#437) feat: Replace custom code with ClaimsPrincipalExtensions that resolves user id and name from IdentityOptions settings. --- .../VirtoCommerce.OrdersModule2.Web.csproj | 2 +- .../VirtoCommerce.OrdersModule.Core.csproj | 2 +- .../VirtoCommerce.OrdersModule.Data.MySql.csproj | 2 +- .../VirtoCommerce.OrdersModule.Data.PostgreSql.csproj | 2 +- .../VirtoCommerce.OrdersModule.Data.SqlServer.csproj | 2 +- .../VirtoCommerce.OrdersModule.Data.csproj | 6 +++--- .../Authorization/OrderAuthorizationHandler.cs | 2 +- src/VirtoCommerce.OrdersModule.Web/module.manifest | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj b/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj index 3ccffd2c..e27da859 100644 --- a/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj +++ b/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj @@ -9,7 +9,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj index 60d32e9d..a21e7b13 100644 --- a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj +++ b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj b/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj index ace6cbc5..7a1f1c74 100644 --- a/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj +++ b/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj @@ -13,7 +13,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj index f8e87132..931d5100 100644 --- a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj +++ b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj @@ -12,7 +12,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj b/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj index 2e170974..49f14335 100644 --- a/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj +++ b/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj @@ -13,7 +13,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj b/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj index d6a29751..15d32e65 100644 --- a/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj +++ b/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/src/VirtoCommerce.OrdersModule.Web/Authorization/OrderAuthorizationHandler.cs b/src/VirtoCommerce.OrdersModule.Web/Authorization/OrderAuthorizationHandler.cs index 95dc591d..7cf2aa9d 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Authorization/OrderAuthorizationHandler.cs +++ b/src/VirtoCommerce.OrdersModule.Web/Authorization/OrderAuthorizationHandler.cs @@ -38,7 +38,7 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext { //Use associated to user memberId and userId as only fall-back value to check "OnlyOrderResponsibleScope" auth rule var memberId = context.User.FindFirstValue(MemberIdClaimType); - var userId = context.User.FindFirstValue(ClaimTypes.NameIdentifier) ?? context.User.FindFirstValue("name"); + var userId = context.User.GetUserId(); memberId = string.IsNullOrEmpty(memberId) ? null : memberId; userId = string.IsNullOrEmpty(userId) ? null : userId; diff --git a/src/VirtoCommerce.OrdersModule.Web/module.manifest b/src/VirtoCommerce.OrdersModule.Web/module.manifest index 20ce224a..0af4eda9 100644 --- a/src/VirtoCommerce.OrdersModule.Web/module.manifest +++ b/src/VirtoCommerce.OrdersModule.Web/module.manifest @@ -4,7 +4,7 @@ 3.833.0 - 3.853.0 + 3.861.0