我们正在使用Open ID Connect在ASP.NET MVC 5中实现Azure AD身份验证。当应用程序在内部运行时,我们具有Windows身份验证,因此没有登录页面或登录按钮。
我们已将[Authorize]属性赋予所有控制器,以便在访问页面之前对用户进行身份验证。下面是启动Auth中的代码。
app.UseKentorOwinCookieSaver();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
CookieManager = new Microsoft.Owin.Host.SystemWeb.SystemWebChunkingCookieManager()
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
RedirectUri = RedirectUri,
ResponseType = OpenIdConnectResponseType.Code,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
AuthenticationFailed = (context) => {
context.HandleResponse();
return Task.FromResult(0);
}
}
});
但是,一旦用户通过身份验证,我们将面临无限循环。我尝试了Internet上的所有解决方案,但问题没有解决。
https://stackoverflow.com/a/37666371/55775
https://github.com/Sustainsys/owin-cookie-saver
https://github.com/aspnet/AspNetKatana/wiki/System.Web-response-cookie-integration-issues