如何在运行时重新加载asp.net核心标识选项

问题描述 投票:1回答:1

我们实施了一个管理系统,允许管理员更改密码复杂性规则。在启动时,这些选项适用于services.AddIdentity<User, Role>(setupAction)中的asp.net核心身份。因此,每当我们重新启动服务器应用程序时,都会应我们如何强制在运行时重新加载这些设置(无需重启应用程序)

c# asp.net asp.net-identity asp.net-core-2.0 asp.net-core-identity
1个回答
2
投票

不要在“启动”中设置选项。而是添加自定义密码验证器:

services.AddIdentity<ApplicationUser, IdentityRole>()
    .AddEntityFrameworkStores<ApplicationDbContext>()
    .AddDefaultTokenProviders()
    .AddPasswordValidator<UsernameAsPasswordValidator<ApplicationUser>>();

来自:https://andrewlock.net/creating-custom-password-validators-for-asp-net-core-identity-2/

© www.soinside.com 2019 - 2024. All rights reserved.