如何解决遵循“阻止跨站点跟踪”选项后如何在Safari中使用Cookie
我注意到在Safari中选中Prevent cross-site tracking
时,无法设置安全cookie。我在此question中非常详细地描述了这个问题。
然后如何在启用该设置的Express中设置安全cookie?
来自MDN:
Values
The SameSite attribute accepts three values:
Lax
Cookies are allowed to be sent with top-level navigations and will be sent along with GET request initiated by third party website. This is the default value in modern browsers.
Strict
Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites.
None
Cookies will be sent in all contexts,i.e sending cross-origin is allowed.
None used to be the default value,but recent browser versions made Lax the default value to have reasonably robust defense against some classes of cross-site request forgery (CSRF) attacks.
None requires the Secure attribute in latest browser versions. See below for more information.
在此article中说,苹果公司正在逐步淘汰Safari中的第三方Cookie。我在网上阅读的内容表明,第三方Cookie是由与该用户访问的域不同的域生成的,用于跨站点跟踪,重定向和广告投放。
我正在一个项目中,前端在Netlify上提供服务,后端来自Heroku。由于后端的域与前端的域不同,因此从节点表示的后端生成的cookie是否被视为第三方cookie?
这是否意味着按照这种安全惯例,我应该在同一服务器上同时拥有前端和后端?
解决方法
Netlify 允许您将请求代理到不同主机名的后端。 https://docs.netlify.com/routing/redirects/rewrites-proxies/#proxy-to-another-service
我不确定它是否会让您以这种方式设置 cookie,Netlify 可能会删除所有标题,您应该尝试。
如果由于某种原因对您不起作用,那么您应该使用相同的主机名为前端和后端提供服务,或者在客户端使用 JS 设置 cookie(我不建议这样做),您也不能从 JS 端设置 HttpOnly cookie。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。