Browse Source

Merge pull request #18367 from abpframework/liangshiwei/identity-patch

Keep the claims when refreshing principal
pull/18372/head
maliming 3 years ago
committed by GitHub
parent
commit
fe03f7c7c9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs
  2. 18
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs

9
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using static Volo.Abp.Identity.AspNetCore.AbpSecurityStampValidatorCallback;
namespace Volo.Abp.Identity.AspNetCore;
@ -41,4 +42,12 @@ public class AbpIdentityAspNetCoreModule : AbpModule
.AddIdentityCookies();
}
}
public override void PostConfigureServices(ServiceConfigurationContext context)
{
Configure<SecurityStampValidatorOptions>(options =>
{
options.UpdatePrincipal();
});
}
}

18
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Identity;
using static Volo.Abp.Identity.AspNetCore.AbpSecurityStampValidatorCallback;
namespace Volo.Abp.Identity.AspNetCore;
public static class SecurityStampValidatorOptionsExtensions
{
public static SecurityStampValidatorOptions UpdatePrincipal(this SecurityStampValidatorOptions options)
{
var previousOnRefreshingPrincipal = options.OnRefreshingPrincipal;
options.OnRefreshingPrincipal = async context =>
{
await SecurityStampValidatorCallback.UpdatePrincipal(context);
await previousOnRefreshingPrincipal?.Invoke(context);
};
return options;
}
}
Loading…
Cancel
Save