Xamarin构成多因素身份验证

时间:2018-02-20 12:23:35

标签: android ios authentication xamarin.forms multi-factor

需要在iOS,Android和Windows UWP的Xamarin Forms Mobile应用程序中进行多重身份验证。用户输入有效的用户名和密码后,应该有第二个因素AUTH - 电话呼叫/短信到注册设备。分步指南和示例应用程序将有助于加快此方案的实施。

1 个答案:

答案 0 :(得分:0)

我想分享的其中一个实现:

  • Azure Active Directory作为目录和多重身份验证服务。您可以使用Azure AD帐户进行访问,或将Azure AD与企业Active Directory域与Active Directory联合身份验证服务集成。在这里,您可以获得帐户管理和多因素基础设施(电话注册,电话/短信服务和政策)
  • Active Directory Authentication Library(ADAL)在Xamarin Forms app中使用。
  • 在Xamarin.Forms应用程序中使用Dependency Service来定义身份验证界面,如:

    public interface IAuthenticator
    {
      Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri);
    }
    
  • 使用程序集依赖关系元数据属性为每个平台(here is all details)提供实现:

    [assembly: Dependency(typeof(MFATestPCL.Droid.Helper.Authenticator))]
    namespace MFATestPCL.Droid.Helper
    
  • 通过共享代码拨打电话:

    var auth = DependencyService.Get<IAuthenticator>();
    authResult = await auth.Authenticate(authority, graphResourceUri, clientId, returnUri);
    

这是完整的GitHub sample Xamarin app repo with step-by-step guide of configuring Azure AD - 提供的iOS,Android和Windows 10 UWP实现。