【发布时间】:2019-03-01 01:50:09
【问题描述】:
我正在使用 MVC5,使用 OpenIdConnect 对 Azure AD 进行身份验证。
我的应用程序在 4 个不同的 Azure AD 应用程序注册下运行; localhost、DEV 版本、UAT 版本和生产版本。
UAT 和生产在 Azure 上同一 Web 服务的不同部署槽下运行。
除了 Azure 中的 UAT 部署槽中的注销功能外,一切都运行良好。当我单击“注销”时,它会将我带到 Microsoft 注销“您已退出您的帐户”。在我导航回 URL 后,它会让我重新登录(我也单击了“不要让我保持登录状态”)。
关于为什么这可能发生在单一环境中的任何想法?除了 URL 和唯一标识符之外,Azure AD 应用注册清单几乎相同。
我正在使用“UseKentorOwinCookieSaver”包。
退出方式:
public void SignOut()
{
HttpContext.GetOwinContext().Authentication.SignOut(
OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType
);
}
Startup.cs:
public void ConfigureAuth(IAppBuilder app)
{ app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseKentorOwinCookieSaver();
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("/Error/message=" + context.Exception.Message);
return Task.FromResult(0);
},
SecurityTokenValidated = context =>
{
OnAuth();
return Task.FromResult(0);
}
},
AuthenticationMode = AuthenticationMode.Passive
}
);
app.Use((context, next) =>
{
// The function to call...
OnAuth();
return next.Invoke();
});
}
【问题讨论】:
标签: asp.net-mvc azure authentication azure-active-directory