亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

SameSite 警告 Chrome 77

SameSite 警告 Chrome 77

慕少森 2021-11-12 10:35:05
自上次更新以來,我遇到了與 SameSite 屬性相關的 cookie 錯誤。cookie 來自第三方開發者(Fontawesome、jQuery、Google Analytics、Google reCaptcha、Google Fonts 等)Chrome控制臺中的錯誤是這樣的。A cookie associated with a cross-site resource at <URL> was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at <URL> and <URL>.(index):1 A cookie associated with a cross-site resource at http://jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.(index):1 A cookie associated with a cross-site resource at http://fontawesome.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.(index):1 A cookie associated with a cross-site resource at http://google.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.我需要在我的本地機器或服務器上做什么,或者只是他們應該在未來版本的庫中實現的一些功能?
查看完整描述

3 回答

?
肥皂起泡泡

TA貢獻1829條經驗 獲得超6個贊

這個控制臺警告不是錯誤或實際問題——Chrome 只是在宣傳這個新標準,以提高開發人員的采用率。

它與您的代碼無關。這是他們的網絡服務器必須支持的東西。

修復的發布日期為 2020 年 2 月 4 日:https : //www.chromium.org/updates/same-site

2020 年 2 月: Chrome 80 Stable 的強制部署:SameSite-by-default 和 SameSite=None-requires-Secure 行為將從2020 年 2 月 17 日那一周開始向 Chrome 80 Stable 推出,適用于最初的有限人群,不包括周一是美國總統日假期。我們將密切監測和評估從最初的有限階段到逐步增加部署的生態系統影響。

有關完整的 Chrome 發布時間表,請參閱此處

我通過添加響應頭解決了同樣的問題

response.setHeader("Set-Cookie", "HttpOnly;Secure;SameSite=Strict");

SameSite防止瀏覽器將 cookie 與跨站點請求一起發送。主要目標是降低跨源信息泄露的風險。它還提供了一些針對跨站點請求偽造攻擊的保護。標志的可能值為 Lax 或 Strict。

此處解釋SameSite cookie

請在應用任何選項之前參考此內容。

希望這對你有幫助。


查看完整回答
反對 回復 2021-11-12
?
慕俠2389804

TA貢獻1719條經驗 獲得超6個贊

更新 - 2021 年 6 月


#same-site-by-default 的 chrome 標志與 Chrome 91 一樣從 Chrome 實驗面板中刪除。


在 Chrome 94 之前,該標志仍可通過啟動選項使用。


對于 macos,使用標志啟動的終端命令是:


// Chrome

open -n -a Google\ Chrome --args --disable-features=SameSiteByDefaultCookies


// Chrome Canary

open -n -a Google\ Chrome\ Canary --args --disable-features=SameSiteByDefaultCookies

更多信息:


2021 年 3 月 18 日:自 Chrome 91 起,標記 #same-site-by-default-cookies 和 #cookies-without-same-site-must-be-secure 已從 chrome://flags 中刪除,因為行為是現在默認啟用。在 Chrome 94 中,命令行標志 --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure 將被刪除。來源:Chromium SameSite 更新頁面。


原始答案 - 2020 年 3 月


如果您在 localhost 上進行測試并且無法控制響應標頭,則可以使用 chrome 標志禁用它。


訪問網址并禁用它:chrome://flags/#same-site-by-default-cookies

http://img1.sycdn.imooc.com//618dd3260001c92607420123.jpg

我需要禁用它,因為 Chrome Canary 大約從 V 82.0.4078.2 開始執行此規則,現在它沒有設置這些 cookie。

注意:我只在我用于開發的 Chrome Canary 中打開這個標志。出于與谷歌引入它相同的原因,最好不要在日常 Chrome 瀏覽中打開該標志。


查看完整回答
反對 回復 2021-11-12
?
慕斯王

TA貢獻1864條經驗 獲得超2個贊

通過向腳本標簽添加 crossorigin 來修復。


來自:https : //code.jquery.com/


<script

  src="https://code.jquery.com/jquery-3.4.1.min.js"

  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="

  crossorigin="anonymous"></script>

完整性和跨域屬性用于子資源完整性 (SRI) 檢查。這允許瀏覽器確保托管在第三方服務器上的資源未被篡改。無論何時從第三方源加載庫,都建議使用 SRI 作為最佳實踐。在 srihash.org 閱讀更多


查看完整回答
反對 回復 2021-11-12
  • 3 回答
  • 0 關注
  • 242 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號