From f623c0b0eefcc64a5e62137c7026cd917d761aa3 Mon Sep 17 00:00:00 2001
From: Ian Clelland The feature policy for a {{Document}} or {{WorkerGlobalScope}}
+ determines whether a feature is allowed or disallowed in that
+ context. A feature which is disallowed should be disabled, or be made
+ unavailable for use in the Document or web worker. Each feature may have a
+ different mechanism for being disabled when disallowed, which should
+ be defined in that feature's specification. A feature is allowed if it is not disallowed. A feature may be allowed by default in a {{Document}} or
+ {{WorkerGlobalScope}}. If a feature is allowed by default, then it
+ is allowed unless a declared policy disallows it, or if
+ in a frame, if its container policy or its parent frame's
+ feature policy disallows it for that frame. A feature may be disallowed by default in a {{Document}} or
+ {{WorkerGlobalScope}}. If a feature is disallowed by default, then it
+ is disallowed unless in a frame, in whose parent frame the feature is
+ allowed, and whose parent frame's feature policy or
+ container policy allows it.Inherited policies
@@ -257,16 +275,18 @@ spec:fetch; type:dfn; text:value
allowlists:
*'self'The feature policy for a Document or WorkerGlobalScope determines whether a feature is allowed or disallowed in that
+ context.
A feature which is disallowed should be disabled, or be made + unavailable for use in the Document or web worker. Each feature may have a + different mechanism for being disabled when disallowed, which should + be defined in that feature’s specification.
+A feature is allowed if it is not disallowed.
+A feature may be allowed by default in a Document or WorkerGlobalScope. If a feature is allowed by default, then it
+ is allowed unless a declared policy disallows it, or if
+ in a frame, if its container policy or its parent frame’s feature policy disallows it for that frame.
A feature may be disallowed by default in a Document or WorkerGlobalScope. If a feature is disallowed by default, then it
+ is disallowed unless in a frame, in whose parent frame the feature is allowed, and whose parent frame’s feature policy or container policy allows it.
In a Document in a top-level browsing context, or in a WorkerGlobalScope, the inherited feature set is based on defined
defaults for each feature.
In a Document in a nested browsing context, the inherited feature
@@ -1687,28 +1699,28 @@
A declared policy is an ordered map from features to allowlists.
-A Document or WorkerGlobalScope is considered feature-policy-aware if it has a declared policy which is
+
A Document or WorkerGlobalScope is considered feature-policy-aware if it has a declared policy which is
not empty.
A Document or WorkerGlobalScope is which is not feature-policy-aware is considered feature-policy-oblivious.
A header policy is a list of policy directives delivered via an HTTP header with the document. This forms the document’s feature policy’s declared policy.
+A header policy is a list of policy directives delivered via an HTTP header with the document. This forms the document’s feature policy’s declared policy.
In addition to the header policy, each frame has a container - policy, which is a policy directive, which may be empty. The container policy can set by attributes on the browsing context + policy, which is a policy directive, which may be empty. The container policy can set by attributes on the browsing context container.
-The container policy for a frame influences the inherited
+ The container policy for a frame influences the inherited
policy of any document loaded into that frame. (See §8.8 Define an inherited policy for
feature)iframe "allowfullscreen",
"allowpaymentrequest",
and "allow"
attributes. Future revisions to this spec may introduce a mechanism to
- explicitly declare the full container policy.
*
- 'self'
- The Feature-Policy HTTP header - field can be used in the response (server to client) to communicate the feature policy that should be enforced by the client.
+ field can be used in the response (server to client) to communicate the feature policy that should be enforced by the client.The header’s value is the §5.1 ASCII serialization of one or more policy directives:.
FeaturePolicy = serialized-feature-policy *("," serialized-feature-policy) @@ -1803,7 +1815,7 @@'src', which represents the origin of the URL in the iframe’s
srcattribute.When not empty, the "
+ an allowlist for each recognized feature to the frame’s container policy, when it is contructed.allow" attribute will result in adding - an allowlist for each recognized feature to the frame’s container policy, when it is contructed.6.3. Additional attributes to support legacy @@ -1820,7 +1832,7 @@
allowfullscreen attribute must have no effect.
Otherwise, the presence of an "allowfullscreen" attribute on an iframe will result in adding an allowlist of
*for the - "fullscreen" feature to the frame’s container policy, when it is + "fullscreen" feature to the frame’s container policy, when it is constructed.This is different from the behaviour of<iframe allow="fullscreen">, and is for compatibility with existing @@ -1837,7 +1849,7 @@allowpaymentrequest attribute must have no effect.
Otherwise, the presence of an "allowpaymentrequest" attribute on an iframe will result in adding an allowlist of
*for - the "payment" feature to the frame’s container policy, when it is + the "payment" feature to the frame’s container policy, when it is constructed.This is different from the behaviour of<iframe allow="payment">, and is for compatibility with existing uses @@ -1856,7 +1868,7 @@
7.1. Integration with HTML
-
DocumentandWorkerGlobalScopeobjects have a Feature Policy, which is populated via the §8.7 Initialize global’s Feature +DocumentandWorkerGlobalScopeobjects have a Feature Policy, which is populated via the §8.7 Initialize global’s Feature Policy from response algorithm that is called during the "Initialising a newDocumentobject" and "Run a Worker" algorithms. @@ -1865,8 +1877,8 @@
- Initialize the feature policy for the
Document-- A feature policy is enforced for - a
DocumentorWorkerGlobalScopeby setting it as theDocumentorWorkerGlobalScope's Feature Policy. +- A feature policy is enforced for + a
DocumentorWorkerGlobalScopeby setting it as theDocumentorWorkerGlobalScope's Feature Policy.The "allowed to use" algorithm calls into §8.9 Is feature enabled in global for origin?, as follows:
@@ -1874,7 +1886,7 @@Replace the current steps #3 and #4 with the following step:
-
@@ -1888,7 +1900,7 @@- If
Document’s feature policy enables the +- If
Document’s feature policy enables the feature indicated byallowattributefor the origin ofDocument, then return true.8. Algorithms
8.1. Process response policy
-Given a response (response) and global object (global), this algorithm returns a declared feature +
Given a response (response) and global object (global), this algorithm returns a declared feature policy.
- Abort these steps if the response’s header list does @@ -1908,7 +1920,7 @@
This section is out of date; the header format is no longer JSON.
Given a string (value) and an origin (origin) - this algorithm will return a declared feature policy.
+ this algorithm will return a declared feature policy.-
- Let policy be an empty list.
- @@ -1979,7 +1991,7 @@
8.5. Process feature policy attributes
-Given an element element, this algorithm returns a declared feature policy, which may be empty.
+Given an element element, this algorithm returns a declared feature policy, which may be empty.
@@ -2084,7 +2096,7 @@
- Let policy be a new policy directive.
- Let valid-features be the result of running Parse allow attribute on the value of element’s
allowattribute. @@ -2042,7 +2054,7 @@8.7. Initialize global’s Feature Policy from response
Given a response (response) and a global object - (global), this algorithm populates global’s Feature Policy
+ (global), this algorithm populates global’s Feature Policy-
- Let inherited policies be a new ordered map.
- Let declared policies be a new ordered map. @@ -2060,7 +2072,7 @@
If inherited policies[feature] is true, then set declared policies[feature] to allowlist.
- Let policy be a new feature policy, with inherited +
- Let policy be a new feature policy, with inherited policy set inherited policies and declared policy set declared policies.
- Enforce the policy policy.
If the allowlist for feature in container policy matches origin, and parent’s inherited policy for feature is Enabled, return Enabled.
- Otherwise return Disabled.
- Otherwise, if feature is allowed by parent’s feature policy for origin, return Enabled. +
- Otherwise, if feature is allowed by parent’s feature policy for origin, return Enabled.
- Otherwise, return Disabled.
- Otherwise, return Enabled. @@ -2097,13 +2109,13 @@
Disabled" if feature should be considered disabled, and "
Enabled" otherwise.-
+- Let policy be global’s Feature Policy +
- Let policy be global’s Feature Policy
- If policy’s inherited policy for feature is Disabled, return "
Disabled".- - If feature is present in policy’s declared + If feature is present in policy’s declared policy:
-
- If the allowlist for feature in policy’s declared policy matches origin, then return "
Enabled". +- If the allowlist for feature in policy’s declared policy matches origin, then return "
Enabled".- Otherwise return "
Disabled".- If feature’s default allowlist is
*, return "Enabled". @@ -2285,6 +2297,8 @@Index
Terms defined by this specification
- allow, in §6.2 +
- allowed, in §4.2 +
- allowed by default, in §4.2
- allowlist, in §4.8
- allow-list, in §5.1
- allowlists, in §4.8 @@ -2294,6 +2308,8 @@
declared policy, in §4.4
- default allowlist, in §4.9
- default allowlists, in §4.9 +
- disallowed, in §4.2 +
- disallowed by default, in §4.2
- enforce, in §7.1
- feature name, in §4.1
- feature-name, in §5.1 @@ -2419,18 +2435,45 @@
#feature-policyReferenced in:
+ + + +
- 4.1. Policy-controlled Features -
- 4.5. Header policies -
- 6.1. Feature-Policy HTTP Header +
- 4.2. Policies (2) (3) +
- 4.5. Header policies +
- 6.1. Feature-Policy HTTP Header Field -
- 7.1. Integration with HTML (2) (3) (4) -
- 8.7. Initialize global’s Feature - Policy from response (2) -
- 8.8. Define an inherited policy for +
- 7.1. Integration with HTML (2) (3) (4) +
- 8.7. Initialize global’s Feature + Policy from response (2) +
- 8.8. Define an inherited policy for feature -
- 8.9. Is feature enabled in +
- 8.9. Is feature enabled in global for origin?
- 7 Combining Policies from different sources
- - 7 Integrations + 8 Integrations
- - 8 Algorithms + 9 Algorithms
-
-- 8.1 Process response policy -
- 8.2 Parse header from value and origin -
- 8.3 Parse policy directive from value and origin -
- 8.4 Merge directive with declared +
- 9.1 Process response policy +
- 9.2 Parse header from value and origin +
- 9.3 Parse policy directive from value and origin +
- 9.4 Merge directive with declared policy -
- 8.5 Process feature policy +
- 9.5 Process feature policy attributes -
- 8.6 Parse allow attribute -
- 8.7 Initialize global’s Feature +
- 9.6 Parse allow attribute +
- 9.7 Initialize global’s Feature Policy from response -
- 8.8 Define an inherited policy for feature -
- 8.9 Is feature enabled in global for origin? +
- 9.8 Define an inherited policy for feature +
- 9.9 Is feature enabled in global for origin?
- 9 IANA Considerations -
- 10 Privacy and Security +
- 10 IANA Considerations +
- 11 Privacy and Security
- Conformance
- Index @@ -1674,10 +1675,9 @@
4 be defined in that feature’s specification.
A feature is allowed if it is not disallowed.
A feature may be allowed by default in a
+ is allowed if no other policy disallows it.DocumentorWorkerGlobalScope. If a feature is allowed by default, then it - is allowed unless a declared policy disallows it, or if - in a frame, if its container policy or its parent frame’s feature policy disallows it for that frame.A feature may be disallowed by default in a
+ is disallowed unless explicitly allowed by policy.DocumentorWorkerGlobalScope. If a feature is disallowed by default, then it - is disallowed unless in a frame, in whose parent frame the feature is allowed, and whose parent frame’s feature policy or container policy allows it.4.3. Inherited policies
@@ -1685,7 +1685,7 @@policy-controlled feature. This inherited policy set determines the initial state (enabled or disabled) of each feature, and - whether it can be controlled by a declared policy in the document. + whether it can be controlled by a declared policy in the document.
In a
Documentin a top-level browsing context, or in aWorkerGlobalScope, the inherited feature set is based on defined defaults for each feature.In a
Documentin a nested browsing context, the inherited feature @@ -1699,28 +1699,28 @@4.4. Declared policies
A declared policy is an ordered map from features to allowlists.
-A
DocumentorWorkerGlobalScopeis considered feature-policy-aware if it has a declared policy which is +A
DocumentorWorkerGlobalScopeis considered feature-policy-aware if it has a declared policy which is not empty.A
DocumentorWorkerGlobalScopeis which is not feature-policy-aware is considered feature-policy-oblivious.4.5. Header policies
-A header policy is a list of policy directives delivered via an HTTP header with the document. This forms the document’s feature policy’s declared policy.
+A header policy is a list of policy directives delivered via an HTTP header with the document. This forms the document’s feature policy’s declared policy.
4.6. Container policies
In addition to the header policy, each frame has a container - policy, which is a policy directive, which may be empty. The container policy can set by attributes on the browsing context + policy, which is a policy directive, which may be empty. The container policy can set by attributes on the browsing context container.
-The container policy for a frame influences the inherited - policy of any document loaded into that frame. (See §8.8 Define an inherited policy for +
The container policy for a frame influences the inherited + policy of any document loaded into that frame. (See §9.8 Define an inherited policy for feature)
-Currently, the container policy cannot be set directly, but is +Currently, the container policy cannot be set directly, but is indirectly set by+ explicitly declare the full container policy.iframe"allowfullscreen", "allowpaymentrequest", and "allow" attributes. Future revisions to this spec may introduce a mechanism to - explicitly declare the full container policy.4.7. Policy directives
@@ -1795,13 +1795,13 @@6.
6.1. Feature-Policy HTTP Header Field
The Feature-Policy HTTP header - field can be used in the response (server to client) to communicate the feature policy that should be enforced by the client.
+ field can be used in the response (server to client) to communicate the feature policy that should be enforced by the client.The header’s value is the §5.1 ASCII serialization of one or more policy directives:.
FeaturePolicy = serialized-feature-policy *("," serialized-feature-policy)When the user agent receives a
+ it MUST process and enforce the serialized policy as described in §8.1 Integration with HTML.Feature-Policyheader field, - it MUST process and enforce the serialized policy as described in §7.1 Integration with HTML.6.2. The
@@ -1815,7 +1815,7 @@allowattribute of theiframeelement'src', which represents the origin of the URL in the iframe’s
srcattribute.When not empty, the "
+ an allowlist for each recognized feature to the frame’s container policy, when it is contructed.allow" attribute will result in adding - an allowlist for each recognized feature to the frame’s container policy, when it is contructed.6.3. Additional attributes to support legacy @@ -1832,7 +1832,7 @@
allowfullscreen attribute must have no effect.
Otherwise, the presence of an "allowfullscreen" attribute on an iframe will result in adding an allowlist of
*for the - "fullscreen" feature to the frame’s container policy, when it is + "fullscreen" feature to the frame’s container policy, when it is constructed.This is different from the behaviour of<iframe allow="fullscreen">, and is for compatibility with existing @@ -1849,7 +1849,7 @@allowpaymentrequest attribute must have no effect.
Otherwise, the presence of an "allowpaymentrequest" attribute on an iframe will result in adding an allowlist of
*for - the "payment" feature to the frame’s container policy, when it is + the "payment" feature to the frame’s container policy, when it is constructed.This is different from the behaviour of<iframe allow="payment">, and is for compatibility with existing uses @@ -1859,16 +1859,42 @@7. Integrations +
7. Combining Policies from different sources
+To determine the effective feature policy for a given document, several + pieces of information are required:
++
+- The default allowlists for all features supported by the user agent +
- The header policy for the document +
- The origin of the document +
If the document is in a frame, then this is also required:
++
+- The feature policy of the document in the parent frame +
- The container policy defined for the document’s frame by its parent. +
Then, for each supported feature, we go through these steps:
++
+ +- Use the parent’s policy and the container policy to define the inherited policy for the new document. + For each feature, if it is allowed by the parent for the new document’s origin, + and not disallowed by the container policy, then it is enabled in the inherited policy. Otherwise, it is disabled. +
- Use the inherited policy and the document’s header policy to determine the + effective policy for the new document. + For each feature, if it is disabled in the inherited policy, then its allowlist will be empty. + If it is enabled, and there is a declaration for that feature in the header policy, then its allowlist will be the declared list from the header. + If it is enabled, and there is no declaration for that feature in the header policy, then its allowlist will be the default allowlist for the feature (with 'self' replaced with the origin of the document). +
+ 8. Integrations
This document defines a set of algorithms which other specifications will use in order to implement the restrictions which Feature Policy defines. The integrations are outlined here for clarity, but those external documents are the normative references which ought to be consulted for detailed information.
- 7.1. Integration with HTML
+8.1. Integration with HTML
-
DocumentandWorkerGlobalScopeobjects have a Feature Policy, which is populated via the §8.7 Initialize global’s Feature +DocumentandWorkerGlobalScopeobjects have a Feature Policy, which is populated via the §9.7 Initialize global’s Feature Policy from response algorithm that is called during the "Initialising a newDocumentobject" and "Run a Worker" algorithms. @@ -1877,16 +1903,16 @@
- Initialize the feature policy for the
Document-- A feature policy is enforced for - a
DocumentorWorkerGlobalScopeby setting it as theDocumentorWorkerGlobalScope's Feature Policy. +- A feature policy is enforced for + a
DocumentorWorkerGlobalScopeby setting it as theDocumentorWorkerGlobalScope's Feature Policy.- -
The "allowed to use" algorithm calls into §8.9 Is feature enabled in +
The "allowed to use" algorithm calls into §9.9 Is feature enabled in global for origin?, as follows:
- Replace the current steps #3 and #4 with the following step:
-
@@ -1897,10 +1923,10 @@- If
Document’s feature policy enables the +- If
Document’s feature policy enables the feature indicated byallowattributefor the origin ofDocument, then return true.
- 8. Algorithms
+9. Algorithms
- 8.1. Process response policy
-Given a response (response) and global object (global), this algorithm returns a declared feature +
9.1. Process response policy
+Given a response (response) and global object (global), this algorithm returns a declared feature policy.
- Abort these steps if the response’s header list does @@ -1910,17 +1936,17 @@
Add a leading "[" U+005B character, and a trailing "]" U+005D character to header. -
- Let feature policy be the result of executing §8.2 Parse header from value and +
- Let feature policy be the result of executing §9.2 Parse header from value and origin on header and global’s origin.
- Return feature policy.
- 8.2. Parse header from value and origin
+9.2. Parse header from value and origin
Given a string (value) and an origin (origin) - this algorithm will return a declared feature policy.
+ this algorithm will return a declared feature policy.
- Let policy be an empty list.
- @@ -1930,16 +1956,16 @@
§8.3 Parse policy directive from +
- Let directive be the result of executing §9.3 Parse policy directive from value and origin on element and origin -
- Run §8.4 Merge directive with declared +
- Run §9.4 Merge directive with declared policy on directive and policy.
- Return policy.
- 8.3. Parse policy directive from value and origin
+9.3. Parse policy directive from value and origin
Given a JSON object (value) and an origin (origin) this algorithm will return a policy @@ -1975,7 +2001,7 @@
- 8.4. Merge directive with declared +
9.4. Merge directive with declared policy
Given a policy direcive (directive) and a declared policy (policy), this algorithm will modify policy to @@ -1989,9 +2015,9 @@
8.5. Process feature policy +
9.5. Process feature policy attributes
-Given an element element, this algorithm returns a declared feature policy, which may be empty.
+Given an element element, this algorithm returns a declared feature policy, which may be empty.
- Let policy be a new policy directive.
- Let valid-features be the result of running Parse allow attribute on the value of element’s
allowattribute. @@ -2030,7 +2056,7 @@8.6. Parse allow attribute
+9.6. Parse allow attribute
Given a list, this algorithm returns a list of feature name keywords, which may be empty.
@@ -2051,36 +2077,36 @@
- 8.7. Initialize global’s Feature +
9.7. Initialize global’s Feature Policy from response
Given a response (response) and a global object - (global), this algorithm populates global’s Feature Policy
+ (global), this algorithm populates global’s Feature Policy
- Let inherited policies be a new ordered map.
- Let declared policies be a new ordered map.
- For each feature supported, -
- Let d be the result of executing §8.1 Process response policy on response and global. +
- Let d be the result of executing §9.1 Process response policy on response and global.
- For each feature -> allowlist of d:
-
- If inherited policies[feature] is true, then set declared policies[feature] to allowlist.
- Let policy be a new feature policy, with inherited +
- Let policy be a new feature policy, with inherited policy set inherited policies and declared policy set declared policies.
- Enforce the policy policy.
- 8.8. Define an inherited policy for feature
+9.8. Define an inherited policy for feature
Given a string (feature) and a browsing context - (context), this algorithm returns the inherited policy for that feature.
+ (context), this algorithm returns the inherited policy for that feature.
- If context is a nested browsing context: @@ -2088,34 +2114,34 @@
Let parent be context’s parent browsing context’s active document.
- Let origin be parent’s origin -
- Let container policy be the result of running §8.5 Process feature policy +
- Let container policy be the result of running §9.5 Process feature policy attributes on context’s browsing context container.
- If feature is a key in container policy:
-
-- If the allowlist for feature in container policy matches origin, and parent’s inherited policy for feature is Enabled, return Enabled. +
- If the allowlist for feature in container policy matches origin, and parent’s inherited policy for feature is Enabled, return Enabled.
- Otherwise return Disabled.
- Otherwise, if feature is allowed by parent’s feature policy for origin, return Enabled. +
- Otherwise, if feature is allowed by parent’s feature policy for origin, return Enabled.
- Otherwise, return Disabled.
- Otherwise, return Enabled.
- 8.9. Is feature enabled in global for origin?
+9.9. Is feature enabled in global for origin?
Given a string (feature) and a global object (global), and an origin (origin), this algorithm returns "
Disabled" if feature should be considered disabled, and "Enabled" otherwise.-
- Let policy be global’s Feature Policy -
- If policy’s inherited policy for feature is Disabled, return "
Disabled". +- Let policy be global’s Feature Policy +
- If policy’s inherited policy for feature is Disabled, return "
Disabled".- - If feature is present in policy’s declared + If feature is present in policy’s declared policy:
-
- If the allowlist for feature in policy’s declared policy matches origin, then return "
Enabled". +- If the allowlist for feature in policy’s declared policy matches origin, then return "
Enabled".- Otherwise return "
Disabled".- If feature’s default allowlist is
*, return "Enabled". @@ -2126,7 +2152,7 @@
- 9. IANA Considerations
+10. IANA Considerations
The permanent message header field registry should be updated with the following registration [RFC3864]:
@@ -2143,7 +2169,7 @@
- @@ -2310,7 +2336,7 @@10. Privacy and Security
+11. Privacy and Security
default allowlists, in §4.9
- disallowed, in §4.2
- disallowed by default, in §4.2 -
- enforce, in §7.1 +
- enforce, in §8.1
- feature name, in §4.1
- feature-name, in §5.1
- feature policy, in §4.2 @@ -2420,7 +2446,7 @@
6.3. Additional attributes to support legacy features -
- 8.3. Parse policy directive from +
- 9.3. Parse policy directive from value and origin (2) @@ -2428,23 +2454,23 @@
Referenced in: @@ -2457,7 +2483,7 @@#feature-name
#allowedReferenced in: @@ -2494,17 +2521,17 @@
#declared-policyReferenced in:
-
@@ -2558,20 +2584,20 @@- 4.2. Policies (2) -
- 4.3. Inherited policies -
- 4.4. Declared policies -
- 4.5. Header policies -
- 8.1. Process response policy -
- 8.2. Parse header from value and +
- 4.2. Policies +
- 4.3. Inherited policies +
- 4.4. Declared policies +
- 4.5. Header policies +
- 9.1. Process response policy +
- 9.2. Parse header from value and origin -
- 8.5. Process feature policy +
- 9.5. Process feature policy attributes -
- 8.9. Is feature enabled in - global for origin? (2) +
- 9.9. Is feature enabled in + global for origin? (2)
6.3.1. allowfullscreen
- 6.3.2. allowpaymentrequest -
- 8.3. Parse policy directive from +
- 9.3. Parse policy directive from value and origin -
- 8.8. Define an inherited policy for +
- 9.8. Define an inherited policy for feature -
- 8.9. Is feature enabled in +
- 9.9. Is feature enabled in global for origin? @@ -2580,7 +2606,7 @@
4.1. Policy-controlled Features
- 4.9. Default Allowlists (2) -
- 8.9. Is feature enabled in +
- 9.9. Is feature enabled in global for origin? (2) @@ -2628,7 +2654,7 @@
-6.1. Feature-Policy HTTP Header Field
- 8.7. Initialize global’s Feature +
- 9.7. Initialize global’s Feature Policy from response