小编And*_*urn的帖子

使用 OpenID Connect 3 验证 MVC 应用程序导致无限重定向循环

问题

我在使用OpenID Connect 3为我正在开发的网站提供授权时遇到问题。

问题是这样的:

  1. 我访问受保护的页面并被重定向到 IdentityServer (OpenID Connect 3)
  2. 身份服务器询问我的用户名和密码
  3. 这些凭据被认为是正常的,然后我将被转发回 MVC 站点。
  4. 这就是出错的地方。由于某种原因,该站点仍然未经身份验证,并且重定向回身份服务器。
  5. 就身份服务器而言,我已经登录,因此它将我重定向回 mvc 应用程序

第 4 步和第 5 步将永远进行下去……好吧,除了达到 cookie 最大数量的限制之外,一切都会结束。

尝试过的解决方案

经过几天的谷歌搜索后,我尝试了以下方法,但到目前为止没有任何效果对我有用。

  1. Kentor Owin Cookie Fix在 Startup 类中..ConfigureAuth 函数

    app.UseKentorOwinCookieSaver();
    
    Run Code Online (Sandbox Code Playgroud)
  2. 1 的变体

    app.UseKentorOwinCookieSaver(PipelineStage.Authenticate);
    
    Run Code Online (Sandbox Code Playgroud)
  3. 替代 cookie 管理器SystemWebCookieManager

           app.UseCookieAuthentication(new CookieAuthenticationOptions
           {
                AuthenticationType = "Cookies",
               CookieManager = new SystemWebCookieManager()
    
           });
    
    Run Code Online (Sandbox Code Playgroud)
  4. 3 SystemWebChunkingCookieManager的变体

           app.UseCookieAuthentication(new CookieAuthenticationOptions
           {
                AuthenticationType = "Cookies",
                CookieManager = new SystemWebChunkingCookieManager()
    
            });
    
    Run Code Online (Sandbox Code Playgroud)
  5. Global.asa 文件中的会话存根

        protected void Session_Start()
        {
    
        }
    
        protected void Session_End() …
    Run Code Online (Sandbox Code Playgroud)

c# authentication asp.net-mvc infinite-loop openid-connect

6
推荐指数
1
解决办法
4704
查看次数