Dan*_*man 15 identity asp.net-core
我点击了这些链接:
这些是我的设置:
services.AddIdentityServer()
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();
services.AddAuthentication()
.AddIdentityServerJwt();
services.ConfigureNonBreakingSameSiteCookies();
// Adjust to this (or similar)
services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
// add an instance of the patched manager to the options:
options.CookieManager = new ChunkingCookieManager();
});
Run Code Online (Sandbox Code Playgroud)
然后在配置中:
app.UseCookiePolicy();
Run Code Online (Sandbox Code Playgroud)
我正在尝试通过 http 运行身份。我在设置某些(但不是全部)cookie 时遇到这些错误,并且我完全无法删除 chrome 中的 cookie
cmi*_*nus 11
万一其他人遇到这个并且仍然有问题。我最终不得不对 NonceCookie 和 CorrelationCookie 属性进行类似的更改才能使它们正常工作。我们的系统使用身份服务器,并位于负载均衡器后面,该负载均衡器也卸载 SSL 部分。
services.AddAuthentication(options =>
{
options.DefaultScheme = "cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("cookies", options =>
{
options.Cookie.Name = "appcookie";
options.Cookie.SameSite = SameSiteMode.Strict;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
})
.AddOpenIdConnect("oidc", options =>
{
options.NonceCookie.SecurePolicy = CookieSecurePolicy.Always;
options.CorrelationCookie.SecurePolicy = CookieSecurePolicy.Always;
...
}
Run Code Online (Sandbox Code Playgroud)
您的代码中一切正常,但您应该更多地配置您的cookie。
添加附加属性 - Secure、HttpOnly和SameSite。AddCookie更多信息请参阅官方文档
例子:
services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
// add an instance of the patched manager to the options:
options.CookieManager = new ChunkingCookieManager();
options.Cookie.HttpOnly = true;
options.Cookie.SameSite = SameSiteMode.None;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20424 次 |
| 最近记录: |