我可以设置Azure Active Directory B2C以使用多个子域吗? 这是我到目前为止所做的:
现在,我想要的是:当我登录" mytest.com"也登录" subdomain.mytest.com"
这可能吗?
我的应用程序是使用OpenId Connect的ASP.NET MVC应用程序 如果需要,我可以提供更详细的信息。
谢谢
答案 0 :(得分:5)
使其有效的行:
app.UseCookieAuthentication(new CookieAuthenticationOptions(){CookieDomain =" .mytest.com"});
当我读到这篇文章时我明白了:https://auth0.com/blog/2014/01/27/ten-things-you-should-know-about-tokens-and-cookies/(第3节)
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions() { CookieDomain = ".mytest.com"});
var options = new OpenIdConnectAuthenticationOptions
{
ClientId = clientIdb2c,
RedirectUri = redirectUri,
PostLogoutRedirectUri = redirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
MessageReceived = (context) =>
{
//AADB2C90091: The user has cancelled entering self-asserted information.
if (!string.IsNullOrEmpty(context.ProtocolMessage.ErrorDescription) && !context.ProtocolMessage.ErrorDescription.StartsWith("AADB2C90091:", StringComparison.OrdinalIgnoreCase))
{
if (context.ProtocolMessage.ErrorDescription.StartsWith("AADB2C99002", StringComparison.OrdinalIgnoreCase))
{
throw new SecurityTokenValidationException("User does not exist. Please sign up before you can sign in.");
}
}
return Task.FromResult(0);
},
RedirectToIdentityProvider = OnRedirectToIdentityProvider,
AuthenticationFailed = AuthenticationFailed,
SecurityTokenValidated = (context) =>
{
//Create the logic to redirect here.
context.AuthenticationTicket.Properties.RedirectUri = "https://sub1.mytest.com";
return Task.FromResult(0);
}
},
Scope = "openid offline_access",
ResponseType = "id_token",
// The PolicyConfigurationManager takes care of getting the correct Azure AD authentication
// endpoints from the OpenID Connect metadata endpoint. It is included in the PolicyAuthHelpers folder.
ConfigurationManager = new PolicyConfigurationManager(
String.Format(CultureInfo.InvariantCulture, aadInstance, tenant, "/v2.0", OIDCMetadataSuffix),
new string[] { SignUpPolicyId, SignInPolicyId, ProfilePolicyId }),
};
app.UseOpenIdConnectAuthentication(options);
}
答案 1 :(得分:0)
只要两个应用程序共享同一个租户。默认情况下,在租户级别启用单点登录,并应用于租户中定义的所有应用程序对象。