【发布时间】:2020-04-27 01:34:47
【问题描述】:
当我设置 httponly=true 的值时。 AutoValidateAntiforgeryTokenAttribute 不验证请求并返回 400 bad request
AntiforgeryTokenSet tokens = antiforgery.GetAndStoreTokens(context);
context.Response.Cookies.Append("XSRF-TOKEN", tokens.RequestToken,
new CookieOptions() { HttpOnly = true});
做完这个cookie后就变安全了,如下图所示
set-cookie: XSRF-TOKEN={{Cookie Value}}; path=/; samesite=lax; httponly
但 AutoValidateAntiforgeryTokenAttribute 返回 400 错误请求
when changed the Value HttpOnly = true to HttpOnly = false
它工作得很好。有没有办法在 asp core 和 angular 7 中将 antiforgerytoken cookie 设置为 httponly。如果它不起作用,请一些机构指导我了解其背后的原因。
【问题讨论】:
标签: c# angular asp.net-core antiforgerytoken cookie-httponly