我遇到了和以前一样的网站Cookie问题。我正在使用AzureAD,当我应用那里的修复程序时,我仍然无法停止IOS12中的无限循环。
我阅读了this page和this one,其中详细介绍了将SameSiteMode设置为None的情况。我是否想念新东西?
.NET Core 2.1,AzureAD
这是我的入门班:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => Configuration.Bind("AzureAd", options))
.AddCookie(options=>options.Cookie.SameSite = SameSiteMode.None)
.Services.ConfigureExternalCookie(options =>
{
options.Cookie = new Microsoft.AspNetCore.Http.CookieBuilder()
{
SameSite = Microsoft.AspNetCore.Http.SameSiteMode.None
};
});
services.AddMvc(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseCors(builder =>
{
// cannot be set to AllowAnyOrigin, because then the response is not accepted, because the credentials are included
builder.WithOrigins("https://*.sharepoint.com")
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowCredentials();
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy(new CookiePolicyOptions()
{
MinimumSameSitePolicy = SameSiteMode.None
});
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
编辑:我将另一个应用程序部署到了没有相同无限循环问题的同一个盒子中。我复制了配置以匹配该应用程序,但仍无法正常工作。两个新的.NET Core 2.1应用程序。
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddAzureAd(options => Configuration.Bind("AzureAd", options))
.AddCookie();
并且:
app.UseAuthentication();
有人可以帮忙吗?
答案 0 :(得分:1)
iOS 13之前的iOS版本无法将“无”识别为SameSite的有效值,因此不会发送cookie。此问题已在iOS 13上修复,但未向后移植到iOS的早期版本。
今天这很重要,因为预计将在2020年2月4日更改Chrome 80中对cookie的处理方式。一旦发布,Chrome将不使用SameSite的cookie视为SameSite = lax,并且不会在iFrame,POST等情况下发送它们等等。不幸的是,由于在早期版本的iOS(和MacOS Safari)中发现的问题,仅在所有cookie上设置SameSite = None不会起作用。
答案 1 :(得分:0)
这似乎与MS和Apple的最新更新一起使用。