成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

PHP - 利用P3P實現(xiàn)跨域

zzzmh / 3428人閱讀

摘要:如何利用實現(xiàn)跨域在開發(fā)中,我們碰到的跨域主要還是糾結(jié)在,頁面中的或者或者跨域的時候,有安全策略限制頁面不帶,但是如果我們加上,就沒有這策略的限制。這也是來突破跨域的可行前提。從上面例子可以看出通過發(fā)送頭信息而實現(xiàn)的跨域。

P3P是什么 P3P

Platform for Privacy Preferences, 是W3C公布的一項隱私保護(hù)推薦標(biāo)準(zhǔn),以為用戶提供隱私保護(hù)。

P3P標(biāo)準(zhǔn)的構(gòu)想是:Web 站點的隱私策略應(yīng)該告之訪問者該站點所收集的信息類型、信息將提供給哪些人、信息將被保留多少時間及其使用信息的方式,如站點應(yīng)做諸如 “本網(wǎng)站將監(jiān)測您所訪問的頁面以提高站點的使用率”或“本網(wǎng)站將盡可能為您提供更合適的廣告”等申明。訪問支持P3P網(wǎng)站的用戶有權(quán)查看站點隱私報告,然后決定是否接受cookie 或是否使用該網(wǎng)站。

如何利用P3P實現(xiàn)跨域

在開發(fā)中,我們碰到的跨域主要還是糾結(jié)在IE,頁面中的IFRAME或者FRAME或者JS跨域的時候,IE有安全策略限制頁面不帶cookie,但是如果我們加上P3P,就沒有這策略的限制。這也是P3P來突破跨域的可行前提。

例子: vist: http://www.first.com/vist.html



    
    Title




http://www.second.com/p3p.php
http://www.second.com/getp3p.php
通過瀏覽器訪問:

http://www.first.com/vist.html

http://www.second.com/getp3p.php

我們發(fā)現(xiàn)訪問first.com/vist.html后,我們并沒有在second.com域發(fā)現(xiàn)設(shè)置上cookie值。

http://www.second.com/p3p.php 增加P3P頭部信息:
再次通過瀏覽器訪問:

http://www.first.com/vist.html

http://www.second.com/getp3p.php

在訪問second.com域后,設(shè)置了first.com域的cookie值。
從上面例子可以看出通過發(fā)送P3P頭信息而實現(xiàn)的跨域。(在Firefox不發(fā)送P3P也能跨域成功)

PHP使用P3P協(xié)議

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.

這里說的跨域主要是設(shè)置cookie的情況,如果是跨域讀取cookie,要保證在對應(yīng)設(shè)置cookie的時候設(shè)置了P3P,否則在讀取的事情IE會屏蔽跨域cookie。

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/26069.html

相關(guān)文章

  • SSO單點登錄的知識儲備

    摘要:規(guī)定的服務(wù)器路徑。的工作原理當(dāng)一個第一次被啟用時,一個唯一的標(biāo)識被存儲于本地的中。利用解決單點登陸跨域問題是公布的一項隱私保護(hù)推薦標(biāo)準(zhǔn),以為用戶提供隱私保護(hù)。 這段時間在看一些關(guān)于SSO單點登錄的問題,寫下一些記錄和一些基礎(chǔ)知識的儲備。 cookie Cookie是由服務(wù)器端生成,發(fā)送給User-Agent(一般是瀏覽器),瀏覽器會將Cookie的key/value保存到某個...

    Dongjie_Liu 評論0 收藏0
  • yii2中session跨域名的問題

    摘要:可是,我們的域名有這三個域名僅僅是不同的環(huán)境,因此,的跨域名訪問就引出來了。無論是一二級域名,和不同域名下的跨域,無非要達(dá)到兩點客戶端訪問同一個所有域名對應(yīng)的服務(wù)器訪問的的數(shù)據(jù)的位置必須一致。 關(guān)閉httponly引起的問題 場景1: 測試A:咦,為什么test環(huán)境登錄不了呢? 程序員:清緩存。 測試B:握草,dev也登錄不了。。。誰看看! 程序員:清緩存。 測試們:。。。唉 場景...

    rollback 評論0 收藏0
  • 項目填坑記-cookie

    摘要:好啦,再次大功告成。由萬維網(wǎng)協(xié)會研制,它為用戶提供了對自己公開信息的更多的控制。支持的站點可以為瀏覽者聲明他們的隱私策略。果然在瀏覽器中打開設(shè)置隱私阻止永不,打開上述設(shè)置之后,跨域種瞬間成功。 前段時間開發(fā)了一個用戶登錄的模塊,需求很簡單,用戶輸入手機(jī)號和驗證碼,我們就會返回給用戶一套身份信息并保存在cookie里面。so easy,于是就有以下代碼: // 大致意思如下,并非真實模塊...

    Lyux 評論0 收藏0
  • 關(guān)于Vue/axios下跨域cookie的處理

    摘要:凡事有例外,以下分別對待不同情況服務(wù)器端配置即可客戶端配置,這樣大部分瀏覽器都支持跨域了,反正新版本下無問題。但放在默認(rèn)設(shè)置下依然出現(xiàn)無法獲取的問題,至此,查資料查到解決存取的跨域問題,依照文中記載,在追加的響應(yīng)頭,解決了下的問題。 一般在生產(chǎn)環(huán)境下盡量可以通過nginx等反向代理,把vue前端和api接口處理成同一端口和域名。 在開發(fā)和測試時,也可以使用兼容性比較好的瀏覽器進(jìn)行。 凡...

    Mike617 評論0 收藏0

發(fā)表評論

0條評論

zzzmh

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<