跨域 cookie 身份验证在 IOS (.net 7) 上失败

问题描述 投票:0回答:0

我正在使用 signalr 来实现聊天服务。在聊天中提交表单时,它会命中一个控制器,该控制器对用户进行身份验证并添加一个 cookie,然后我使用该 cookie 通过信号器保持聊天状态。这在除 IOS 上运行的浏览器之外的所有浏览器上都能完美运行。身份验证是在与聊天窗口显示的不同域中完成的。

当我检查网络选项卡并进行比较时,我在浏览器中看到了对身份验证帖子的“aspnetcore.cookies”响应,但在 IOS 上却不起作用。

我在启动时尝试了各种设置,这就是当前的设置

 services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
                .AddCookie(options =>
                {
                    options.ExpireTimeSpan = TimeSpan.FromDays(1);
                    options.SlidingExpiration = true;
                    options.LoginPath = "/Identity/Account/Login"; // If the LoginPath is not set here, ASP.NET Core will default to /Account/Login
                    options.LogoutPath = "/Identity/Account/Logout"; // If the LogoutPath is not set here, ASP.NET Core will default to /Account/Logout
                    options.AccessDeniedPath = "/Identity/Account/AccessDenied"; // If the AccessDeniedPath is not set here, ASP.NET Core will default to /A
                    options.Cookie.SameSite = SameSiteMode.None;
                    options.Cookie.IsEssential = true;
                    
                });
            services.AddSession(
                options =>
                {
                    options.Cookie.SameSite = SameSiteMode.None;
                });
 services.AddAuthorization(options =>
            {
                options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
            });
            services.AddSignalR(hubOptions =>
                {
                    hubOptions.EnableDetailedErrors = true;
                });
 app.UseRouting();
            app.UseCookiePolicy(new CookiePolicyOptions
            {
                MinimumSameSitePolicy = SameSiteMode.None
            });
            app.UseAuthentication();
            app.UseAuthorization();
ios cookies signalr cross-domain .net-7.0
© www.soinside.com 2019 - 2024. All rights reserved.