【发布时间】:2019-02-16 17:28:14
【问题描述】:
我想将Same-site cookie attribute 添加到我在 Tomcat Web 应用程序中使用的 cookie 中,添加 HttpOnly 属性在 web.xml 文件中添加以下定义就足够了:
<session-config>
<session-timeout>240</session-timeout>
<cookie-config>
<http-only>true</http-only>
</cookie-config>
</session-config>
Same-site 属性呢?是否可以以与 http-only 相同的方式设置它,例如:<same-site>true</same-site>?
Same-site cookie 的定义:
同一站点 cookie(née “First-Party-Only”(née “First-Party”))允许 服务器以减轻 CSRF 和信息泄漏攻击的风险 通过断言特定的 cookie 只应与 从同一可注册域发起的请求。
【问题讨论】:
-
Ivan Tsenov 写了如何将它添加到 Tomcat 的
context.xml。