keepassxc-browser icon indicating copy to clipboard operation
keepassxc-browser copied to clipboard

Add support for managed settings using 3rdparty policy

Open varjolintu opened this issue 4 months ago • 9 comments

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.

varjolintu avatar Oct 20 '24 12:10 varjolintu