0
我的情况的布局如下。Azure AD在多个网站上使用相同的Toke登录
我有两个应用程序,一个将通过Azure广告进行身份验证,并且根据登录的用户将显示第二个应用程序的链接。 在localhost中,它可以正常工作,第二个应用程序可以读取第一个应用程序中使用的令牌并对用户进行身份验证。
但是,当我在我的DEV环境中发布时,第二个应用程序无法读取cookie,并且要验证用户,Azure页面将再次显示。
看来,在本地主机的cookie访问没有任何问题,但是当我从IIS上发布有效的域这不会发生。
我的代码:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
//app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
CookieName = "NameOfMyApp",
CookieDomain = "mydomain.com"
});
app.Use(async (context, next) => { await next.Invoke(); });
app.UseOpenIdConnectAuthentication(this.CreateB2EOptions());
app.Use(async (context, next) => { await next.Invoke(); });
}
private OpenIdConnectAuthenticationOptions CreateB2EOptions()
{
return new OpenIdConnectAuthenticationOptions
{
Authority = string.Format(b2e.AadInstance, "common"),
ClientId = b2e.ClientId,
RedirectUri = sso.RedirectUri,
PostLogoutRedirectUri = sso.RedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications { AuthenticationFailed = this.AuthenticationFailed },
TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = false, SaveSigninToken = true },
AuthenticationMode = AuthenticationMode.Passive,
AuthenticationType = "OpenIdConnect-B2E"
};
}
请您澄清一下您的意思是“第二个应用程序可以读取第一个应用程序中使用的令牌并对用户进行身份验证”。 ?如何在第二个应用程序中使用openid connect或使用自己的代码实现这一目标? –