Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for managed settings using 3rdparty policy #2366

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

varjolintu
Copy link
Member

@varjolintu varjolintu commented Oct 20, 2024

Adds support for distributing global settings to the extension using 3rdparty policy. Includes a new managed_storage.json file that describes the settings that can be set. The schema file must be formatted correctly or the extension does not start because of failed validation.

Easiest way to test this was to use web-ext with Firefox that had the policy JSON file added. Just made sure I deleted all storage data from the temporary extension before launching it again. That caused the settings to be an empty Object, and the getter for managed settings will be called.

Example policy.json file:

{
  "policies": {
    "3rdparty": {
      "Extensions": {
        "[email protected]": {
          "settings": {
            "defined-custom-fields": {
              "https://example.com": {
                "fields": [
                  [
                    "/html/body/table/tbody/tr[10]/td[4]/table/tbody/tr/td/table/tbody/tr[2]/td[4]/form/table/tbody/tr[2]/td[2]/input",
                    "INPUT password form_password "
                  ]
                ],
                "password": [
                  "/html/body/table/tbody/tr[10]/td[4]/table/tbody/tr/td/table/tbody/tr[2]/td[4]/form/table/tbody/tr/td[2]/input",
                  "INPUT text form_username "
                ],
                "username": [
                  "/html/body/table/tbody/tr[10]/td[4]/table/tbody/tr/td/table/tbody/tr[2]/td[4]/form/table/tbody/tr[2]/td[2]/input",
                  "INPUT password form_password "
                ]
              }
            },
            "passkeys": true,
            "sitePreferences": [
              {
                "allowIframes": false,
                "ignore": "ignoreNothing",
                "improvedFieldDetection": false,
                "url": "https://example.com",
                "usernameOnly": true
              }
            ]
          }
        }
      }
    }
  }
}

Related links:
https://extensionworkshop.com/documentation/enterprise/enterprise-development/#how-to-add-policy
https://developer.chrome.com/docs/extensions/reference/manifest/storage

Fixes #2365.

@mihakrumpestar
Copy link

mihakrumpestar commented Oct 20, 2024

I tried to test it.

Build using npm run build -- --skip-translations which builds the extension, but it won't get installed due to error:

Installer error

Do I need the Transifex API token?

@varjolintu
Copy link
Member Author

I need to check the build script with the new file addition. For testing you do not need to build this. Just load the temporary extension directly from the sources.

@mihakrumpestar
Copy link

I did read the instructions for development now. Loading as temporary add-on also does not seem to work completely properly:

Temporary add-on

The settings are then missing Passkey options, which are also absent when I export config from temporary add-on.
Note that I am using a completely new and clean profile, so I am loading this without any prior or old setting.

@varjolintu
Copy link
Member Author

That warning in the temporary extension page is expected, becase the default manifest.json is using some properties that are Chromium-only. It still works.

@varjolintu
Copy link
Member Author

Do you mean the passkeys option is missing even if you have enabled it?

@mihakrumpestar
Copy link

mihakrumpestar commented Oct 20, 2024

Do you mean the passkeys option is missing even if you have enabled it?

No, the Passkey section in UI is missing altogether.

image

Left is the current one I am using (the official one), right is the dev temporary one (both in different profiles).

@varjolintu
Copy link
Member Author

varjolintu commented Oct 20, 2024

I cannot reproduce that kind of error. I tried this with both temporary profile and a newly created profile with web-ext. Does the JavaScript console say anything?

@mihakrumpestar
Copy link

I am sorry. I was trying some things and forgot I changed to master branch.

Furthermore, I tested again (on the correct branch this time) and the settings for Passkeys are indeed there, and the 3rdparty extension settings also get applied successfully. Tested on NixOS.

TLDR: It is working.

@varjolintu
Copy link
Member Author

Did some fixes to the defined-custom-fields. Those should also work now.

@varjolintu varjolintu marked this pull request as ready for review October 20, 2024 19:22
@varjolintu varjolintu added this to the 1.9.4 milestone Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for setting the settings using 3rdparty policy
2 participants