摘要:如何利用實(shí)現(xiàn)跨域在開(kāi)發(fā)中,我們碰到的跨域主要還是糾結(jié)在,頁(yè)面中的或者或者跨域的時(shí)候,有安全策略限制頁(yè)面不帶,但是如果我們加上,就沒(méi)有這策略的限制。這也是來(lái)突破跨域的可行前提。從上面例子可以看出通過(guò)發(fā)送頭信息而實(shí)現(xiàn)的跨域。
P3P是什么 P3P
Platform for Privacy Preferences, 是W3C公布的一項(xiàng)隱私保護(hù)推薦標(biāo)準(zhǔn),以為用戶提供隱私保護(hù)。
P3P標(biāo)準(zhǔn)的構(gòu)想是:Web 站點(diǎn)的隱私策略應(yīng)該告之訪問(wèn)者該站點(diǎn)所收集的信息類型、信息將提供給哪些人、信息將被保留多少時(shí)間及其使用信息的方式,如站點(diǎn)應(yīng)做諸如 “本網(wǎng)站將監(jiān)測(cè)您所訪問(wèn)的頁(yè)面以提高站點(diǎn)的使用率”或“本網(wǎng)站將盡可能為您提供更合適的廣告”等申明。訪問(wèn)支持P3P網(wǎng)站的用戶有權(quán)查看站點(diǎn)隱私報(bào)告,然后決定是否接受cookie 或是否使用該網(wǎng)站。
如何利用P3P實(shí)現(xiàn)跨域在開(kāi)發(fā)中,我們碰到的跨域主要還是糾結(jié)在IE,頁(yè)面中的IFRAME或者FRAME或者JS跨域的時(shí)候,IE有安全策略限制頁(yè)面不帶cookie,但是如果我們加上P3P,就沒(méi)有這策略的限制。這也是P3P來(lái)突破跨域的可行前提。
例子: vist: http://www.first.com/vist.htmlhttp://www.second.com/p3p.php http://www.second.com/getp3p.php 通過(guò)瀏覽器訪問(wèn):Title
http://www.first.com/vist.html
http://www.second.com/getp3p.php
http://www.second.com/p3p.php 增加P3P頭部信息: 再次通過(guò)瀏覽器訪問(wèn):我們發(fā)現(xiàn)訪問(wèn)first.com/vist.html后,我們并沒(méi)有在second.com域發(fā)現(xiàn)設(shè)置上cookie值。
http://www.first.com/vist.html
http://www.second.com/getp3p.php
在訪問(wèn)second.com域后,設(shè)置了first.com域的cookie值。
從上面例子可以看出通過(guò)發(fā)送P3P頭信息而實(shí)現(xiàn)的跨域。(在Firefox不發(fā)送P3P也能跨域成功)
header("P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"");
JS使用P3P協(xié)議xmlhttp.setRequestHeader("P3P" ,"CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"");
P3P的頭部參數(shù)解釋P3P Header is present: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR" Compact Policy token is present. A trailing "o" means opt-out, a trailing "i" means opt-in. CURa Information is used to complete the activity for which it was provided. ADMa Information may be used for the technical support of the Web site and its computer system. DEVa Information may be used to enhance, evaluate, or otherwise review the site, service, product, or market. PSAo Information may be used to create or build a record of a particular individual or computer that is tied to a pseudonymous identifier, without tying identified data (such as name, address, phone number, or email address) to the record. This profile will be used to determine the habits, interests, or other characteristics of individuals for purpose of research, analysis and reporting, but it will not be used to attempt to identify specific individuals. PSDo Information may be used to create or build a record of a particular individual or computer that is tied to a pseudonymous identifier, without tying identified data (such as name, address, phone number, or email address) to the record. This profile will be used to determine the habits, interests, or other characteristics of individuals to make a decision that directly affects that individual, but it will not be used to attempt to identify specific individuals. OUR We share information with ourselves and/or entities acting as our agents or entities for whom we are acting as an agent. BUS Info is retained under a service provider"s stated business practices. Sites MUST have a retention policy that establishes a destruction time table. The retention policy MUST be included in or linked from the site"s human-readable privacy policy. UNI Non-financial identifiers, excluding government-issued identifiers, issued for purposes of consistently identifying or recognizing the individual. These include identifiers issued by a Web site or service. PUR Information actively generated by the purchase of a product or service, including information about the method of payment. INT Data actively generated from or reflecting explicit interactions with a service provider through its site -- such as queries to a search engine, or logs of account activity. DEM Data about an individual"s characteristics -- such as gender, age, and income. STA Mechanisms for maintaining a stateful session with a user or automatically recognizing users who have visited a particular site or accessed particular content previously -- such as HTTP cookies. PRE Data about an individual"s likes and dislikes -- such as favorite color or musical tastes. COM Information about the computer system that the individual is using to access the network -- such as the IP number, domain name, browser type or operating system. NAV Data passively generated by browsing the Web site -- such as which pages are visited, and how long users stay on each page. OTC Other types of data not captured by the above definitions. NOI Web Site does not collected identified data. DSP The privacy policy contains DISPUTES elements. COR Errors or wrongful actions arising in connection with the privacy policy will be remedied by the service.
這里說(shuō)的跨域主要是設(shè)置cookie的情況,如果是跨域讀取cookie,要保證在對(duì)應(yīng)設(shè)置cookie的時(shí)候設(shè)置了P3P,否則在讀取的事情IE會(huì)屏蔽跨域cookie。
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://hztianpu.com/yun/26069.html
摘要:規(guī)定的服務(wù)器路徑。的工作原理當(dāng)一個(gè)第一次被啟用時(shí),一個(gè)唯一的標(biāo)識(shí)被存儲(chǔ)于本地的中。利用解決單點(diǎn)登陸跨域問(wèn)題是公布的一項(xiàng)隱私保護(hù)推薦標(biāo)準(zhǔn),以為用戶提供隱私保護(hù)。 這段時(shí)間在看一些關(guān)于SSO單點(diǎn)登錄的問(wèn)題,寫(xiě)下一些記錄和一些基礎(chǔ)知識(shí)的儲(chǔ)備。 cookie Cookie是由服務(wù)器端生成,發(fā)送給User-Agent(一般是瀏覽器),瀏覽器會(huì)將Cookie的key/value保存到某個(gè)...
摘要:可是,我們的域名有這三個(gè)域名僅僅是不同的環(huán)境,因此,的跨域名訪問(wèn)就引出來(lái)了。無(wú)論是一二級(jí)域名,和不同域名下的跨域,無(wú)非要達(dá)到兩點(diǎn)客戶端訪問(wèn)同一個(gè)所有域名對(duì)應(yīng)的服務(wù)器訪問(wèn)的的數(shù)據(jù)的位置必須一致。 關(guān)閉httponly引起的問(wèn)題 場(chǎng)景1: 測(cè)試A:咦,為什么test環(huán)境登錄不了呢? 程序員:清緩存。 測(cè)試B:握草,dev也登錄不了。。。誰(shuí)看看! 程序員:清緩存。 測(cè)試們:。。。唉 場(chǎng)景...
摘要:好啦,再次大功告成。由萬(wàn)維網(wǎng)協(xié)會(huì)研制,它為用戶提供了對(duì)自己公開(kāi)信息的更多的控制。支持的站點(diǎn)可以為瀏覽者聲明他們的隱私策略。果然在瀏覽器中打開(kāi)設(shè)置隱私阻止永不,打開(kāi)上述設(shè)置之后,跨域種瞬間成功。 前段時(shí)間開(kāi)發(fā)了一個(gè)用戶登錄的模塊,需求很簡(jiǎn)單,用戶輸入手機(jī)號(hào)和驗(yàn)證碼,我們就會(huì)返回給用戶一套身份信息并保存在cookie里面。so easy,于是就有以下代碼: // 大致意思如下,并非真實(shí)模塊...
摘要:凡事有例外,以下分別對(duì)待不同情況服務(wù)器端配置即可客戶端配置,這樣大部分瀏覽器都支持跨域了,反正新版本下無(wú)問(wèn)題。但放在默認(rèn)設(shè)置下依然出現(xiàn)無(wú)法獲取的問(wèn)題,至此,查資料查到解決存取的跨域問(wèn)題,依照文中記載,在追加的響應(yīng)頭,解決了下的問(wèn)題。 一般在生產(chǎn)環(huán)境下盡量可以通過(guò)nginx等反向代理,把vue前端和api接口處理成同一端口和域名。 在開(kāi)發(fā)和測(cè)試時(shí),也可以使用兼容性比較好的瀏覽器進(jìn)行。 凡...
閱讀 2311·2023-04-26 00:00
閱讀 3581·2021-09-24 10:37
閱讀 3643·2021-09-07 09:58
閱讀 1635·2019-08-30 15:56
閱讀 2296·2019-08-30 13:11
閱讀 2387·2019-08-29 16:38
閱讀 1080·2019-08-29 12:58
閱讀 2010·2019-08-27 10:54