Open Bug 1771731 Opened 2 years ago Updated 2 years ago

Add support for "managed_schema" for the "browser.storage.managed" API

Categories

(WebExtensions :: Storage, enhancement, P5)

enhancement

Tracking

(Not tracked)

People

(Reporter: Manuel.Spam, Unassigned)

References

Details

(Whiteboard: [design-decision-needed])

The easiest and most convenient way to deal with "browser.storage.managed" is to just check this for a default first and then continue with "browser.storage.local" or "browser.storage.sync". This way it is possible to set defaults for all possible settings when deploying an Add-on.

The problem with this: While, so far, I could somehow be sure that my settings can only ever have the values that can be set using the provided options_page (and have to be of the type and within the ranges I enforce here), I could now get unsupported types or out of range values defined using "admin defined policies".

In Google Chrome this problem is already solved. Add-on developers can pretty easily define exactly how provided "managed settings" have to look like. To make this possible, Chrome uses an JSON schema validator and developers can provide a schema for managed properties using the "managed_schema" manifest.json key: https://developer.chrome.com/docs/extensions/mv2/manifest/storage/

It is OK if Mozilla does not want to enforce this (like Chrome does) but if it is defined in "manifest.json", then it should be used, so developers have a convenient way of prefiltering whatever gets provided using policies.

Potential benefits:

  • Extension code receive a consistent, validated view of supported values.
  • There would be a central registry of managed extension prefs (e.g. Chrome uses this to render the details in the chrome://policies UI).

Risks:

  • Using the schema validator on external schema's - is this supported/safe?.
  • JSON schema validation is not fully standardized. Even in Firefox, there are 3 different implementations of JSON schema parsers.
Severity: -- → N/A
Priority: -- → P5
Whiteboard: [design-decision-needed]

So this was a conscious decision by me because at the tiem I didn't feel like managed_schema provided much benefit.

If the extension provides a GPO or specific documentation on what settings are available, the schema didn't really seem necessary.

But I do understand what you're saying about needing extra validation because of this.

Although honestly, I've seen very little adoption of browser.storage.managed at all...

Hi,

Any ETA on this?

With respect to the adoption, I guess most of the developers just don't know about this functionality. I guess here Mozilla should be promoting it via its channels, pointing every time to the documentation about adding the support to the extensions. Also, at the AMO there could be some distinction for the add-ons that support policies/sync, this way it would quickly become a well-known feature and probably something requested by users in masses.

On the other hand, when this feature is explained to the devs, some of them decide to postpone the implementation with some objections, real or perceived.

One of the considerations is the subj of this bugreport.

Others are related to the priorities, e.g. what happens if the extension is already initialized, how the values supplied via policies should be considered? Should there be enforced values, what happens with lists (e.g. a whitelist, when enforced, is it allowed to add new values)? E.g. https://github.com/Cookie-AutoDelete/Cookie-AutoDelete/issues/1394#issuecomment-1138232866.

The documentation that is available at https://extensionworkshop.com/documentation/enterprise/adding-policy-support-to-your-extension/ is great and one could quickly implement the basic policies functionality following it, but maybe it could be expanded with a FAQ for the questions already mentioned and be upended with new ones as they are asked?

Hmmmm. I tried to test one of my Add-ons today because I want to push a fix for a minor issue.

And when running "web-ext run" I was greeted with the following error in the "Browser Console":

Error: Managed storage manifest not found undefined

So is "managed_schema" already a thing now? When was this added? Is it documented somewhere? And if it is added already, then this Bug maybe should be closed?

The documentation, at least, does not mention it anywhere: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json

Edit: I'm not alone: https://github.com/sourcegraph/sourcegraph/issues/16339

Sorry for the noise. I'm not sure if this always was an issue or if the behavior changed with a recent change, but the above error is shown (maybe only on Linux) if the "policies.json" manifest file is missing. See: https://bugzil.la/1784446

Solution: Wrap in try/catch block to ignore this error...

You need to log in before you can comment on or make changes to this bug.