Chrome91 SameSite cookies 配置

吐槽君 分类:javascript

    因为开发环境需要, 我们把浏览器的same-site-by-default-cookiescookies-without-same-site-must-be-secure两项都在flag里禁用了。但是更新到91版本后, Chromium直接把选项给关了(Chromium的更新日志),而且设置成默认开启, 那就没办法在flag里设置了。

The flags #same-site-by-default-cookies and #cookies-without-same-site-must-be-secure have been removed from chrome://flags as of Chrome 91, as the behavior is now enabled by default. In Chrome 94, the command-line flag --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure will be removed.

    也就是说我们可以通过命令行的形式在APP启动的时候作为启动参数传入:

    1. (Windows)在右击Chrome/Edge的快捷方式, 点击"属性"。在"目标(Target)"属性中末尾加上--flag-switches-begin --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure --flag-switches-end,然后重启浏览器。
  • 2.(Mac)通过脚本给浏览器添加启动参数
    • 2.1 新建一个文本(如ChromeStart
    • 2.2 然后编辑ChromeStart
      #!/bin/bash
      "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --args --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure
       
    • 2.3 给脚本添加执行权限
      sudo chmod u+x "ChromeStart"
       
    • 2.4 关闭浏览器,执行脚本,就可以了

    但是这两种办法不是长久之计, Chromium 94后会连comman-line的方式也移除, 按照官方的说法是因为如果任由开发者禁用这两个选项, 开发者就会变成容易被攻击的目标。 因此为了保护开发者, Chromium选择逐渐关闭这个通道。

Mac Chrome添加启动参数

回复

我来回复
  • 暂无回复内容