Browse Source

Do not set `IHttpAuthenticationFeature`.

Because it uses the same object as `IAuthenticateResultFeature`.
pull/21398/head
maliming 2 years ago
parent
commit
984a775217
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 11
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs

11
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<IAbpClaimsPrincipalFactory>();
var user = await abpClaimsPrincipalFactory.CreateDynamicAsync(context.User);
authenticateResultFeature.AuthenticateResult = AuthenticateResult.Success(new AuthenticationTicket(user, authenticationType));
var httpAuthenticationFeature = context.Features.Get<IHttpAuthenticationFeature>();
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)

Loading…
Cancel
Save