紀錄工作經驗、相關知識,解決技術相關問題。

HTML, 網站相關, 資訊相關

瀏覽器 同源策略 Same-origin policy – 簡單說明

同源策略 英文Same-origin policy ,主要是針對 Web瀏覽器跨域安全性的專有名詞。

同源策略可防止惡意腳本通過頁面修改等方式,使網頁訪問不再規範內的惡意檔案 or 敏感資訊。

同源策略的條件必須符合 :

  • 域名相同
  • 埠號相同
  • 協定相同

以上條件一項不符,均視為不符合同源策略。

以 https://domain.com/aaa.html?abc=1為例子,以下列舉範例,來判斷是否符合同源策略

URLOutcomeReason
https://domain.com/aaa.html?aaa/b.html同源
http://domain.com/aaa.html?abc=1不同源協定不同
https://sub.domain.com/aaa.html?abc=1不同源域名不同
https://domain.com:55/aaa.html?abc=1不同源埠號不同
https://domain.com/aaa?s=123同源
同源策略 – 範例說明

4 留言

  1. Do you mind if I quote a couple of your articles as long asI provide credit and sources back to your website?My blog site is in the very same niche as yours and my users would certainly benefit from some of the information you present here.Please let me know if this okay with you. Thanks!

  2. Very nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

  3. I have read your article carefully and I agree with you very much. This has provided a great help for my thesis writing, and I will seriously improve it. However, I don’t know much about a certain place. Can you help me?

  4. I have read your article carefully and I agree with you very much. This has provided a great help for my thesis writing, and I will seriously improve it. However, I don’t know much about a certain place. Can you help me?

發表迴響