Jos*_* K. 6 cookies safari cross-site node.js express
我注意到,当Prevent cross-site tracking在 Safari 中检查时,我无法设置安全 cookie。我在这个问题中非常详细地描述了这个问题。
那么如何在启用该设置的情况下在 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.
Run Code Online (Sandbox Code Playgroud)
这篇文章称,Apple 正在逐步淘汰 Safari 中的第三方 cookie。我在网上读到,第三方 cookie 是由与用户访问的域不同的域生成的,用于跨站点跟踪、重定向和广告服务。
我正在开发一个项目,前端由 Netlify 提供,后端由 Heroku 提供。由于后端与前端具有不同的域,因此从 Node Express 后端生成的 Cookie 是否被视为第三方 Cookie?
这是否意味着按照这种安全实践,我应该在同一台服务器上拥有前端和后端?
Ars*_*yan -2
Netlify 允许您将请求代理到不同主机名上的后端。 https://docs.netlify.com/routing/redirects/rewrites-proxies/#proxy-to-another-service
我不确定它是否会让您以这种方式设置 cookie,Netlify 可能会删除所有标头,您应该尝试一下。
如果由于某种原因这对您不起作用,那么您应该从同一主机名提供前端和后端服务,或者在客户端使用 JS 设置 cookie(我不推荐),而且您也不能设置 HttpOnly cookie从JS端。
| 归档时间: |
|
| 查看次数: |
1860 次 |
| 最近记录: |