【问题标题】:MVC Client with Identity Server4 authentication falls into infinite Redirect loop具有 Identity Server4 身份验证的 MVC 客户端陷入无限重定向循环
【发布时间】:2021-10-21 21:55:45
【问题描述】:

我开发了管理客户端和用户的 Identity Server Admin 以及管理身份验证的 IdentityServer4。这两个应用程序都是在 Asp.Net Core 3.1 中开发的

Identity Sever Admin 是多租户应用程序,作为主机子域中的租户名称。

我已在 Azure App Service 中部署,并为 Identity Server Admin(MVC Client) 和 IdentityServer4 使用了自定义域

身份服务器管理员 - https://tenant1.identityserveradmin.comhttps://tenant2.identityserveradmin.comhttps://allegion.identityserveradmin.com

IdentityServer4 - https://sts.identityserveradmin.com

在上述领域

tenant1 和tenant2 完美运行,因为它通过 Identity server4 进行身份验证并保存 cookie,但 allegion 域不保存 cookie 并进入重定向循环

下面是我在 startup.cs 中的 cookie 配置

services.AddAuthentication(options =>
                {
                    options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultChallengeScheme = AuthenticationConsts.OidcAuthenticationScheme;

                    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultForbidScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultSignOutScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                })
                    .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme,
                        options =>
                        {
                            options.Cookie.Name = adminConfiguration.IdentityAdminCookieName;

                            options.Cookie.SameSite = SameSiteMode.None;
                            options.Cookie.HttpOnly = true;
                            options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
                            options.Events = new CookieAuthenticationEvents
                            {
                                OnSignedIn = context => OnSignedIn(context, adminConfiguration, httpContextAccessor),
                                OnSigningIn = context => OnSigningIn(context, adminConfiguration, httpContextAccessor),
                                OnValidatePrincipal = context => OnValidatePrincipal(context, adminConfiguration, httpContextAccessor)
                            };
                        })

不知道为什么会发生奇怪的事情,请帮忙。

问候, 马亨德兰。

【问题讨论】:

    标签: c# .net cookies identityserver4 setcookie


    【解决方案1】:

    我自己解决了这个问题,客户端密码不匹配,cookie 没有经过验证,所以这个问题发生了。 现在解决了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-28
      • 2019-11-06
      • 2013-04-07
      • 1970-01-01
      • 2017-11-07
      • 2013-03-19
      • 2015-08-11
      相关资源
      最近更新 更多