Aspnet Boilerplate GetValidTwoFactorProvidersAsync returns an empty list

为君一笑 提交于 2019-12-13 20:29:26

问题


I am using Aspnet Boilerplate to manage a multi-tenant system. I am currently attempting to turn on 2-factor authentication, which is baked into the boilerplate. I have logged into the host and turned on 2FA (because I understand that it can't be on in the tenanats unless it's on in the host first). Once I do this, I can now see the settings to turn 2FA on in each tenant (which I have done). My problem is that, while the host users are indeed asked for a code as expected, no tenant users ever are. I've narrowed it down to the following issue. Upon successful login, this is called:

var signInResult = await _signInManager.SignInOrTwoFactorAsync(loginResult, loginModel.RememberMe);

This always returns RequiresTwoFactor == false. The reason for this is that, within this call, a call is made to:

GetValidTwoFactorProvidersAsync(TUser user)

which in turn calls the function of the same name within .NET Core. This call returns an empty list, meaning that I have no TwoFactor Providers registered. Which is weird, because logging in as a host I get providers, but as a tenant it returns empty. Is there anything I'm missing why this might be happening. Also, where exactly in the boilerplate code are those (email and SMS) providers registered in the first place?


回答1:


See the configuration for 2FA on AbpZeroSettingProvider.cs

But the implementation of two factor authentication is not included in Aspnet Boilerplate.

It's a feature in AspNetZero, see https://aspnetzero.com/Documents/Development-Guide-Core#two-factor-login



来源:https://stackoverflow.com/questions/52709499/aspnet-boilerplate-getvalidtwofactorprovidersasync-returns-an-empty-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!