大网数据广告活动
域与目录服务

Infinite redirection between OpenID Connect app and Entra ID

· 52CE 我爱测

Provides guidance for troubleshooting infinite redirection between the OpenID Connect app and Entra ID.

Summary

This article describes an infinite redirection issue that exists between an OpenID Connect (OIDC) application and Microsoft Entra ID.

Symptoms

When you browse to a website that's built by using an OpenID Connect (OIDC) app and Microsoft Entra ID, the browser enters an infinite loop that forms between the website and the Microsoft Entra ID authentication process.

The issue specifically occurs when you browse the website by using the HTTP protocol. When you use HTTPS, the issue doesn't occur.

Cause

The .AspNet.Cookies cookie isn't sent in HTTP requests because of its secure attribute.

Solution: Enforce HTTPS navigation

To resolve the issue, enforce HTTPS navigation for the site. HTTPS is always recommended for sites that require authentication.

Workaround

If your scenario requires the initial navigation to occur over HTTP, you can customize the Cookies Authentication middleware to allow the authentication AspNet cookie for both the HTTP and HTTPS schemes by setting the CookieSecure attribute to CookieSecureOption.Never, as shown in the following Startup.Auth.cs file.

Note: This workaround isn't recommended for production environments because it compromises security by allowing cookies to be sent over HTTP.

public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                CookieSecure = CookieSecureOption.Never
            });

            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
                {
                    ClientId = clientId,
                    Authority = authority,

}
        }

This issue is discussed also in this ASP.NET Security Blog article (Issue #219).

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors (upstream author metadata: bachoang). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 12/26/2024
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。