我们使用Azure AD多租户应用程序成功验证来自不同订阅的Azure AD用户,但无法验证Windows Live ID帐户。
要对实时ID帐户进行身份验证,我们将Windows Live ID身份提供程序与Azure Access Control Service(ACS)一起使用,它与Azure AD单租户应用程序配合使用,但我们很难在订阅中对Azure AD用户进行身份验证,通过使用Azure AD多租户应用程序完成。
我们关注此博客https://msdn.microsoft.com/en-us/library/azure/dn486924.aspx,它适用于单租户应用程序,但是当我们尝试将Azure AD应用程序配置为多租户并使用ACS配置它时会收到以下错误。 enter image description here 我们是否有任何方法可以对Windows Live ID进行身份验证并使用Azure多租户应用程序?
答案 0 :(得分:2)
您可以通过完全跳过ACS并在目录租户中配置Microsoft帐户来验证多租户应用程序中的Microsoft帐户(实时ID)用户。一个问题是,使用Microsoft帐户进行身份验证需要您通过在URL中实例化租户来完全指定身份验证端点。您不能使用/ common端点,因为它依赖于用户的家庭租户,而MSA用户没有。
答案 1 :(得分:0)
您在帐户控制器中添加以下代码
public void SignIn(string directoryName = "common")
{
// Send an OpenID Connect sign-in request.
if (!Request.IsAuthenticated)
{
HttpContext.GetOwinContext().Environment.Add("Authority", string.Format(ConfigurationManager.AppSettings["ida:Authority"] + "OAuth2/Authorize", directoryName));
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
}
并在您的startup.auth.cs
中添加此块 app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = ClientId,
Authority = Authority,
TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
{
// we inject our own multitenant validation logic
ValidateIssuer = false,
},
Notifications = new OpenIdConnectAuthenticationNotifications()
{
RedirectToIdentityProvider = (context) =>
{
object obj = null;
if (context.OwinContext.Environment.TryGetValue("Authority", out obj))
{
string authority = obj as string;
if (authority != null)
{
context.ProtocolMessage.IssuerAddress = authority;
}
}
if (context.OwinContext.Environment.TryGetValue("DomainHint", out obj))
{
string domainHint = obj as string;
if (domainHint != null)
{
context.ProtocolMessage.SetParameter("domain_hint", domainHint);
}
}
context.ProtocolMessage.RedirectUri = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path);
context.ProtocolMessage.PostLogoutRedirectUri = new UrlHelper(HttpContext.Current.Request.RequestContext).Action
("Index", "Home", null, HttpContext.Current.Request.Url.Scheme);
//context.ProtocolMessage.Resource = GraphAPIIdentifier;
context.ProtocolMessage.Resource = AzureResourceManagerIdentifier;
return Task.FromResult(0);
},
...
}
点击"登录"请求" Azure AD名称"。将该变量传递给Account / SignIn操作。如果用户将出现在上述Azure AD中,则登录将成功。