#341: Permissions policy (formerly feature policy) evolution

Visit on Github.

Opened Feb 7, 2019

こんにちはTAG!

Special delivery courtesy of your request of me earlier this evening. I would like to draw your attention to two aspects of Feature policy. Feature policy itself was reviewed by the TAG while I was a member and generally judged to be splendid. However, being a 'framework spec' (my term for a spec that creates a scaffold on which elements of its behaviour will operate, but where those elements are defined elsewhere or not within the same process), it has developed in a way that might attract further interest:

  1. Whilst policies are generally named for the behaviour that they allow, in some cases they are named after the behaviour that results from denying the policy. 'lazyload' is one such policy. In the default case, where no policy is defined or it is defined and allowed for the relevant origin, the document follows the instructions of the lazyload attribute, which defaults to immediate ('eager', if you like) loading. If a policy is defined and disallowed for the relevant origin, the page forces all elements to be lazyloaded. This could be considered counterintuitive, and if the TAG were to take a view, I would imagine it would be on the principle rather than this specific instance.

  2. Feature Policies are booleans, but there is a proposal to make them parameteri[sz]ed. Some of the examples cited for parameterised policies seem to suggest that the value would be required ('allowed-image-formats' seems not to make sense without a value), while others which already exist as boolean policies become quite different when in parameterised 'mode' (eg lazyload), and still others seem like they are fundamentally booleans so the behaviour if a value is supplied is undefined (eg document-write).

Ref:

Discussions

Comment by @triblondon Feb 8, 2019 (See Github)

Also see https://github.com/w3c/webappsec-feature-policy/issues/163#issuecomment-461830471

Discussed Mar 1, 2019 (See Github)

[punt

Discussed Mar 1, 2019 (See Github)

[punting

Discussed May 1, 2019 (See Github)

Dan: bigger issue rather than review?

Sangwhan: I'd be happy to kick to face-to-face.

Dan: How should we structure? Bring in people who are working in the feature policy space? Facilitate a discussion between us and Andrew and others? These issues still seem to be quite open.

Sangwhan: I think I need to digest the potential of what is currently shipped and get myself filled in on background, and then involve other people.

David: Also related to an issue we have elsewhere, maybe design-principles, about six different mechanisms for blocking stuff.

David: Maybe need work before the face-to-face if it's going to be useful -- need to figure out how.

Dan: I'm commenting on the issue.

Dan: Will bump a week. Let us know if you have ideas about how to structure discussion. This isn't a review in that sense, but feels like something we ought to be paying attention to.


Alice: Does it feel like something that could feed into design principles doc? Would be very specific.

Tess: definitely

Tess: feature policy is a client api, naming is part of good api design. One of issues here about how weird the naming is. There's a broader question about design of the feature in the future.

David: I don't feel like it's too specific for design-principles doc. Would be good if other spec bits link to it.

Tess: There's a separate doc about promises. We don't have a separate thing for the things you should think about when designing a feature policy; it should go in the catch all

Discussed May 1, 2019 (See Github)

David: i think we need to bump this to f2f [and 349]

Tess: do we know if Andrew will call in for it?

Dan: I will reach out to Andrew

Comment by @torgo May 1, 2019 (See Github)

Trying to determine if we should try to have a more comprehensive session on this at our next f2f to progress this. @triblondon do you think this would be helpful?

Comment by @torgo May 1, 2019 (See Github)

We also discussed today the idea of adding some material to the design principles document on this topic.

Comment by @triblondon May 1, 2019 (See Github)

FP is now potentially splitting into three separate standards: one for sandboxing behaviours within an iframe, one for imposing conditions on the document itself, and one for dealing with permission-requiring features.

My original points are still valid (1 and 2 in the OP), and I’d add that the TAG might do well to consider whether it’s good to bake feature-policy’s idea of developer best practice into the platform itself, and if so whether there needs to be any additional scrutiny of what that best practice is judged to be.

Most web specifications offer a new feature. Developers decide whether to use it. It’s in some sense a market mechanism with a balance of power and interests. Feature policy takes features away or constrains how a developer might use them, without the developer having much say in the matter, though ultimately maybe for the benefit of everyone?

Comment by @torgo May 22, 2019 (See Github)

@triblondon brought to our attention: https://github.com/w3c/webappsec-feature-policy/issues/282 https://github.com/w3c/webappsec-feature-policy/issues/296

Comment by @triblondon May 22, 2019 (See Github)

See also: https://github.com/w3c/webappsec-feature-policy/issues/282#issuecomment-486267212

Comment by @cynthia May 22, 2019 (See Github)

We discussed this twice during the Iceland F2F. One was with @triblondon, and @dbaron and I had a separate discussion on this as a breakout.

While it is somewhat unclear what is expected from us here, so we considered it as a open-ended request for the time being.

First of all, we are supportive of the spec being split into three different things - we believe this allows better division of work and being able to ship the less-complex parts sooner.

One of the points that came up is that for cases where a feature policy will make an API disappear (e.g. deprecation of document.write) there is plumbing that will be required in WebIDL, and the fact that there is a path for disabling these features seems like a useful addition to the platform.

Spec templates should ideally be updated to have a separate fixed section for feature policy identifer, to be 1) machine parsing friendly and 2) easier to find by readers. This does beg the question whether or not long term there should be a registry, which is more of a question than a suggestion.

There should definitely be strong guidance on the naming conventions of these following the points above, so the initial status is either as positive as possible of as negative as possible, and not named against the default state of the policy. This relates to an issue that we should be looking at: w3ctag/design-principles#41

Comment by @clelland May 29, 2019 (See Github)

Thanks for looking at this, @cynthia (and the rest of TAG)!

One of the points that came up is that for cases where a feature policy will make an API disappear (e.g. deprecation of document.write) there is plumbing that will be required in WebIDL, and the fact that there is a path for disabling these features seems like a useful addition to the platform.

This is good to hear -- it's not something that has been proposed recently; in all of the cases where we thought we'd want to have FP control visibility of JS attributes, we eventually concluded that having methods exist, but fail in some well-defined way was less disruptive. Long term, though, actually removing APIs from the platform would be a good thing, I think.

This does beg the question whether or not long term there should be a registry, which is more of a question than a suggestion.

We're tracking this idea in https://github.com/w3c/webappsec-feature-policy/issues/244 -- I was orignally opposed, but I've come around to the idea that there should probably be one, for interoperability of nothing else.

There should definitely be strong guidance on the naming conventions of these following the points above, so the initial status is either as positive as possible of as negative as possible, and not named against the default state of the policy.

Can you give an example of what you mean by "not named against the default state of the policy"? Are there current features which we should be looking at renaming before they get too much traction?

Comment by @cynthia Sep 10, 2019 (See Github)

Can you give an example of what you mean by "not named against the default state of the policy"? Are there current features which we should be looking at renaming before they get too much traction?

Apologies for the delay, fell through the cracks in the new work process.

This remark might have been confusing - as for the list of shipping feature policy names I think we don't have any examples (based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy) - but this was a meta comment on guidelines on how to name feature policies from a spec author perspective. For example, if there is a new platform feature X that is enabled by default, we'd like to see guidelines on naming the policy X rather than "disable-X" or "no-X".

One example would be "no-document-write" - since the tense of current feature policies are positive, it seems like it could be potentially flipped for consistency. One bit we overlooked when making this remark was about how to deal with feature deprecation through FP, in which case it does feel like having a distinction could be a helpful hint on a feature on it's way out. (e.g. no-document-write is an example). (We're not sure how unoptimized-images or oversized-images fit into this, though.)

Unfortunately for the last bit we don't have any concrete proposals, and would like to hear what you think.

Comment by @hober Dec 5, 2019 (See Github)

@cynthia @dbaron @plinss: We should discuss this in an upcoming APAC/California breakout.

Comment by @clelland Jun 30, 2020 (See Github)

Hi TAG!

The Feature Policy spec has evolved a bit since this request was filed, and I'd like to move forward with shipping our implementation, now that we have fairly solid consensus between Chromium and Gecko implementers, and at least informal nods of support from WebKit.

The biggest changes now are:

I'd appreciate any comments on the header change, if the TAG has thoughts there. There is a migration plan for Chrome (Parse both headers if they exist, and give precedence to the Permissions-Policy header, if it exists, on a feature-by-feature basis), but I believe that Firefox would like to ship Permissions-Policy out-of-the-gate.

Discussed Jul 1, 2020 (See Github)

[Ran out of time before we got to this.

Comment by @dbaron Sep 24, 2020 (See Github)

Documenting the issues in the initial comment here (such as naming consistency) is closely related to #525 and to w3ctag/design-principles#41. It also relates to w3ctag/design-principles#144.

Comment by @dbaron Sep 24, 2020 (See Github)

The list of Permissions-Policy features will be useful for understanding the naming consistency. I'm not sure where the corresponding list for Document-Policy lives, though.

Comment by @cynthia Sep 24, 2020 (See Github)

Looking at the list of permission policies, it is a lot more consistent in terms of design after the split. I at least am happy about this change, and it makes it much nicer to define a clear pattern (e.g. if you have a permission, you must also have a corresponding permission policy) on what specs should do.

It seems like that the first concern (at least the specific part) has been addressed by removing lazyload? Are there any others that follow this pattern that we are unaware of?

The second part of the concern looks like it is now in document policy, so we'll track that there.

It feels like in the registry it would be helpful to have a column to distinguish permission-gated (e.g. geolocation) features, quasi-permission-gated (e.g. autoplay), and the other kind. (which I don't have a good name for - e.g. execution-while-out-of-viewport)

Comment by @cynthia Sep 24, 2020 (See Github)

I just looked at document policy and the second issue seems to be addressed, still figuring out if the first is though, as it looks like that has been refactored into document policy. (So please ignore my comment regarding lazyload above)

Discussed Jan 1, 2021 (See Github)

Feature policy was split into permissions policy and document policy. All the issues we had were either addressed or moved into document policy. Closing.

Comment by @cynthia Jan 26, 2021 (See Github)

While the first issue has not been addressed, it looks like this is being tracked in https://github.com/WICG/document-policy/issues/6. We don't think there is much for us to do here as the split between permissions/document policy made it much more consistent. I've stuck my name on the watchers list for the lazyload issue to see where the discussion goes (currently it seems a bit dormant) - but aside from that I think we think it's fine to close this.