Skip to content

Commit 09c74af

Browse files
authored
Partition the policy cache (#143)
This adds the network partition key from FETCH to the policy cache, so that policies stored in one embedding context cannot be used in any other context. Closes: 138
1 parent 124133c commit 09c74af

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

index.html

+38-13
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ <h2>Dependencies</h2>
124124
<ul>
125125
<li><dfn data-cite="!FETCH#concept-request-client">client</dfn></li>
126126
<li><dfn data-cite="!FETCH#cors-preflight-request">CORS-preflight request</dfn></li>
127+
<li><dfn data-cite="!FETCH#determine-the-network-partition-key">determine the network partition key</dfn></li>
127128
<li><dfn data-cite="!FETCH#extract-header-list-values">extract header list values</dfn></li>
128129
<li><dfn data-cite="!FETCH#header-list-contains">header list contains</dfn></li>
129130
<li><dfn data-cite="!FETCH#concept-header-name" data-lt="header names">header name</dfn></li>
130131
<li><dfn data-cite="!FETCH#concept-header-value">header value</dfn></li>
131132
<li><dfn data-cite="!FETCH#http-network-fetch">HTTP-network fetch</dfn></li>
132133
<li><dfn data-cite="!FETCH#http-network-or-cache-fetch">HTTP-network-or-cache fetch</dfn></li>
134+
<li><dfn data-cite="!FETCH#network-partition-key">network partition key</dfn></li>
133135
<li><dfn data-cite="!FETCH#redirect-status" data-lt="redirects">redirect status</dfn></li>
134136
<li><dfn data-cite="!FETCH#concept-request-header-list">request header list</dfn></li>
135137
<li><dfn data-cite="!FETCH#concept-response" data-lt="responses">response</dfn></li>
@@ -490,7 +492,7 @@ <h2>Policy cache</h2>
490492
<p>
491493
A conformant user agent MUST provide a <dfn>policy cache</dfn>, which is a
492494
storage mechanism that maintains a set of <a>NEL policies</a>, keyed by
493-
their <a data-lt="policy origin">origins</a>.
495+
(<a>network partition key</a>, <a>origin</a>) tuples.
494496
</p>
495497

496498
<p>
@@ -501,7 +503,8 @@ <h2>Policy cache</h2>
501503

502504
<ul>
503505
<li>Insert, update, and delete <a>NEL policies</a>.</li>
504-
<li>Retrieve the <a>NEL policy</a>, if any, for an <a>origin</a>.</li>
506+
<li>Retrieve the <a>NEL policy</a>, if any, for a given <a>origin</a>
507+
and <a>network partition key</a>.</li>
505508
<li>Clear the cache.</li>
506509
</ul>
507510
</section>
@@ -699,6 +702,11 @@ <h2>Process policy headers</h2>
699702
Let <var>origin</var> be <var>request</var>'s <a>origin</a>.
700703
</li>
701704

705+
<li>
706+
Let <var>key</var> be the result of calling <a>determine the network
707+
partition key</a>, given <var>request</var>.
708+
</li>
709+
702710
<li>
703711
Let <var>header</var> be the value of the <a>response header</a> whose
704712
name is <code>NEL</code>.
@@ -818,9 +826,9 @@ <h2>Process policy headers</h2>
818826

819827
<li>
820828
If there is already an entry in the <a>policy cache</a> for
821-
<var>origin</var>, replace it with <var>policy</var>; otherwise,
822-
insert <var>policy</var> into the <a>policy cache</a> for
823-
<var>origin</var>.
829+
(<var>key</var>, <var>origin</var>), replace it with
830+
<var>policy</var>; otherwise, insert <var>policy</var> into the
831+
<a>policy cache</a> for (<var>key</var>, <var>origin</var>).
824832
</li>
825833

826834
</ol>
@@ -831,18 +839,28 @@ <h2>Process policy headers</h2>
831839
<h2>Report delivery</h2>
832840

833841
<section>
834-
<h2>Choose a policy for an origin</h2>
842+
<h2>Choose a policy for a request</h2>
835843

836844
<p>
837-
Given an <a>origin</a> (<var>origin</var>), this algorithm determines
838-
which <a>NEL policy</a> in the <a>policy cache</a> should be used to
839-
generate reports for <a>network requests</a> to <var>origin</var>.
845+
Given a <a>network request</a> (<var>request</var>), this algorithm
846+
determines which <a>NEL policy</a> in the <a>policy cache</a> should be
847+
used to generate reports for that <a>network request</a>.
840848
</p>
841849

842850
<ol class="algorithm">
843851

844852
<li>
845-
If there is an entry in the <a>policy cache</a> for <var>origin</var>:
853+
Let <var>origin</var> be <var>request</var>'s <a>origin</a>.
854+
</li>
855+
856+
<li>
857+
Let <var>key</var> be the result of calling <a>determine the network
858+
partition key</a>, given <var>request</var>.
859+
</li>
860+
861+
<li>
862+
If there is an entry in the <a>policy cache</a> for (<var>key</var>,
863+
<var>origin</var>):
846864
<ol>
847865
<li>Let <var>policy</var> be that entry.</li>
848866
<li>If <var>policy</var> is not <a>expired</a>, return it.</li>
@@ -855,8 +873,8 @@ <h2>Choose a policy for an origin</h2>
855873

856874
<ol>
857875
<li>
858-
If there is an entry in the <a>policy cache</a> for <var>parent
859-
origin</var>:
876+
If there is an entry in the <a>policy cache</a> for
877+
(<var>key</var>, <var>parent origin</var>):
860878
<ol>
861879
<li>Let <var>policy</var> be that entry.</li>
862880
<li>
@@ -1021,7 +1039,7 @@ <h2>Extract response headers</h2>
10211039

10221040
<li>
10231041
Let <var>policy</var> be the result of executing <a
1024-
href="#choose-a-policy-for-an-origin"></a> on <var>origin</var>. If
1042+
href="#choose-a-policy-for-a-request"></a> on <var>request</var>. If
10251043
<var>policy</var> is <code>no policy</code>, return null.
10261044
</li>
10271045

@@ -1897,6 +1915,13 @@ <h2>Privacy Considerations</h2>
18971915
persistent tracker.
18981916
</p>
18991917

1918+
<p>
1919+
Additionally, the NEL <a>policy cache</a> is partitioned using the
1920+
<a>network partition key</a>, so that a <a>NEL policy</a> stored for a
1921+
site in one embedding context will not be used in a different context
1922+
(for instance, when embedded by a different top-level site.)
1923+
</p>
1924+
19001925
<p>
19011926
NEL is intended to augment existing server-side monitoring. NEL reports
19021927
should only be sent to the owner of the service being requested. For

0 commit comments

Comments
 (0)