我在使用Identity Server 4时遇到问题。这是一个常见问题,需要SameSite = None和安全cookie。当我设法将SameSite设置为None时,我没有将cookie设置为安全。
我尝试过在线搜索,但找不到任何完整的解决方案。因为我没有经验,所以我也需要在哪里使用那部分代码的信息。
我正在使用ASP.NET Core 3.1。
谢谢
您可以这样设置cookie设置
services.AddIdentityServer()
.AddInMemoryClients(Clients.Get())
.AddInMemoryIdentityResources(Resources.GetIdentityResources())
.AddInMemoryApiResources(Resources.GetApiResources())
.AddDeveloperSigningCredential()
.AddTestUsers(TestUsers.Users);
services.AddAuthentication("MyCookie")
.AddCookie("MyCookie", options =>
{
options.ExpireTimeSpan = ...;
});
有关更多信息,请阅读Cookie authentication。