我有一个ASP.NET Core 2.0解决方案,并且我从版本1.1复制了SMS 2FA的功能。一切顺利,我收到了带有代码的短信,并验证了代码和_signInManager.TwoFactorSignInAsync
的结果。成功= true。
但是,我在启动中定义了2个架构。普通用户和管理员用户。管理员用户已启用2FA,普通用户未启用。
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Account/LogIn";
options.ExpireTimeSpan = TimeSpan.FromMinutes(5);
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
});
services.AddAuthentication(options =>
{
options.DefaultScheme =
CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie("User", options =>
{
options.LoginPath = "/Account/LogIn";
options.AccessDeniedPath = "/Account/AccessDenied";
})
.AddCookie("Admin", options =>
{
options.LoginPath = "/Admin/Login";
options.AccessDeniedPath = "/Admin/AccessDenied";
});
然后在AdminController上我有这个:[Authorize(AuthenticationSchemes = "Admin")]
流程如下:
有什么想法我做错了吗?