【发布时间】:2021-08-08 00:53:21
【问题描述】:
我对 chrome 没有任何问题。这是我面临问题的边缘浏览器。我试图清除缓存。已删除 cookie。重置浏览器。没有任何效果。我在登录时不断收到无限循环。它最终失败并显示消息 “我们无法让您登录。请重试。”。任何帮助表示赞赏。
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
{
options.Events.OnRedirectToIdentityProviderForSignOut = async context =>
{
Console.WriteLine("intercepted");
};
});
var azureAd = new AzureAd();
Configuration.GetSection("AzureAd").Bind(azureAd);
services.AddControllersWithViews();
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
var url = "https://abc.xyz.com/platform/signin-oidc";
//var url = "https://localhost:5001/platform/signin-oidc";
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
{
options.SaveTokens = true;
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProvider = async context =>
{
context.ProtocolMessage.RedirectUri = url;
//context.Response.Headers.Add("Referrer-Policy", "no-referrer");
await Task.FromResult(0);
}
};
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCors("CorsPolicy");
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
//app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "platform",
pattern: "/platform/{controller=Home}/{action=Index}/{id?}");
});
}
编辑
我确实在开发者工具的网络标签中看到了这个:
【问题讨论】:
-
我不是 100% 确定,但我认为这与 SameSite cookie 政策有关:docs.microsoft.com/en-us/aspnet/core/security/…
-
如果使用上述方法不起作用,请进行网络跟踪(wireshark/fiddler/etc.)并按照 cookie 确保将它们传递给 MS。
-
@ThiagoCustodio 试过了。它不起作用。它仅在部署 btw 之后发生。本地..我没有遇到任何问题。
-
@blockingHD 希望我知道该怎么做。
标签: c# .net azure asp.net-core asp.net-core-3.1