【问题标题】:MVC application Azure AD and custom authentication supportMVC 应用程序 Azure AD 和自定义身份验证支持
【发布时间】:2017-12-28 21:23:27
【问题描述】:

我们在 MVC 应用程序中实现了基于自定义令牌的身份验证。现在,我们还使用 OpenID Connect 启用了 Azure AD,如下所述。

 app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
       {
           ClientId = ADClientId,
           Authority = ADauthority,
           Notifications = new OpenIdConnectAuthenticationNotifications()
           {
               RedirectToIdentityProvider = (context) =>
               {

                   if (context.Request.Path.Value == "/Account/ExternalLogin" || (context.Request.Path.Value == "/Account/LogOff"))
                   {

                       string appBaseUrl = context.Request.Scheme + "://" + context.Request.Host + context.Request.PathBase;
                       context.ProtocolMessage.RedirectUri = appBaseUrl + "/";
                       context.ProtocolMessage.PostLogoutRedirectUri = appBaseUrl;
                   }
                   else
                   {

                       context.State = Microsoft.Owin.Security.Notifications.NotificationResultState.Skipped;
                       context.HandleResponse();
                   }
                   return Task.FromResult(0);
               },
           }

我们需要像下面这样修改场景。如果您有任何技术建议,请告诉我 1) 登录页面 - 获取用户电子邮件地址

2) 检查用户 ID,如果那是 Azure AD 电子邮件 - 然后转到用户输入密码的 Microsoft 身份验证页面

3) 如果用户输入自定义用户id,则在应用程序的内部认证流程中处理密码页面

【问题讨论】:

  • 我了解您想要实现的目标。但我认为它应该构建在您的应用程序中。我们与 Azure AD 没有任何关系。因为您需要集成两个身份验证端点。
  • 是的。我可以直接重定向到预设电子邮件地址的 oAuth Azure 密码窗口吗?
  • 能否做到这一点很难说。但是理论上是可以的。对于这种情况,它与 Azure AD 无关,它只是指向您的应用程序本身的链接。

标签: azure asp.net-mvc-4 authentication azure-active-directory


【解决方案1】:

如果您的要求是在检查提供的电子邮件地址是否来自您的 Azure Active Directory 租户中的现有用户帐户时进行的,那么您可以使用Microsoft Graph 进行查询和确认。

例如,以下 Graph Api REST 调用将有助于确定提供的电子邮件地址是否是租户中现有用户的电子邮件地址。

https://graph.microsoft.com/v1.0/users?$filter=startswith(mail%2C+'email@domain.com')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-07
    • 2014-09-28
    • 2020-03-06
    • 2019-05-28
    • 2022-10-25
    • 2019-09-24
    • 2018-05-19
    相关资源
    最近更新 更多