From 984a77521758e33b535db51c6bed9e6b9729588d Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 20 Nov 2024 13:01:34 +0800 Subject: [PATCH] Do not set `IHttpAuthenticationFeature`. Because it uses the same object as `IAuthenticateResultFeature`. --- .../Security/Claims/AbpDynamicClaimsMiddleware.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs index b2bbb78e7b..36012a123b 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs @@ -2,7 +2,6 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Middleware; @@ -27,12 +26,10 @@ public class AbpDynamicClaimsMiddleware : AbpMiddlewareBase, ITransientDependenc var abpClaimsPrincipalFactory = context.RequestServices.GetRequiredService(); var user = await abpClaimsPrincipalFactory.CreateDynamicAsync(context.User); - authenticateResultFeature.AuthenticateResult = AuthenticateResult.Success(new AuthenticationTicket(user, authenticationType)); - var httpAuthenticationFeature = context.Features.Get(); - if (httpAuthenticationFeature != null) - { - httpAuthenticationFeature.User = authenticateResultFeature.AuthenticateResult.Principal; - } + authenticateResultFeature.AuthenticateResult = AuthenticateResult.Success(new AuthenticationTicket( + user, + authenticateResultFeature?.AuthenticateResult?.Properties, + authenticationType)); } if (context.User.Identity?.IsAuthenticated == false)