mozilla / multi-account-containers

Firefox Multi-Account Containers lets you keep parts of your online life separated into color-coded tabs that preserve your privacy. Cookies are separated by container, allowing you to use the web with multiple identities or accounts simultaneously.
https://addons.mozilla.org/firefox/addon/multi-account-containers/
Mozilla Public License 2.0
2.64k stars 323 forks source link

Assign domains to containers through Firefox policies #2601

Open DamienCassou opened 7 months ago

DamienCassou commented 7 months ago

Before submitting a bug report

Step to reproduce

It is possible to specify containers through policies: this is documented at https://mozilla.github.io/policy-templates/#containers and looks like the following in policy.json:

{
  "policies": {
    "Containers": {
      "Default": [
        {
          "name": "My container",
          "icon": "pet",
          "color": "turquoise"
        }
      ]
    }
  }
}

This is great. Unfortunately, there is no way to (pre-)assign domains to these containers. I would like to write something like the following:

{
  "policies": {
    "Containers": {
      "Default": [
        {
          "name": "My container",
          "icon": "pet",
          "color": "turquoise",
          "domains": ["example.org"]
        }
      ]
    }
  }
}

With such a configuration, opening example.org would be automatically done in the "My container" container without requiring manual configuration by each user.

Actual behavior

There is no way to associate a domain to a given container.

Expected behavior

example.org should be attached to "My container" without requiring the user to click "Always open this site in"

Additional informations

This was requested in https://github.com/mozilla/multi-account-containers/issues/2565.

Provide a copy of Troubleshooting Information page (optional)

No response

dannycolin commented 7 months ago

cc @mkaply

I like this idea. However, there are a few things to consider:

There might be other concerns but that's what came to my mind at the moment.

DamienCassou commented 7 months ago

Firefox policies are only created on first run of a Firefox profile

I just experimented with this. I think containers are populated from policies if the containers.json file doesn't exist in the profile directory yet. This is a problem I think: a company should be able to deploy an updated policy with new containers for example.

Another problem I see is that containers.json assign an ID to each container but the policies do not. This is a problem for add-ons which rely on container IDs, e.g., Cookie-AutoDelete.

Is there some room to change how policies affect this add-on or is it forged in stone? I'm thinking about something like this for policies:

{
    "policies": {
        "Containers": {
            "LockCreate": true,
            "LockDelete": true,
            "Default": [
                {
                    "id": 1,
                    "name": "My container",
                    "icon": "pet",
                    "color": "turquoise"
                    "domains": ["example.org"],
                    "lockDomains": true
                }
            ]
        }
    }
}

Changes based on existing policies:

I kept the lower case property names in each container (e.g., "name" instead of "Name") but it seems like "Containers" is the only policy not using upper camel case.

mkaply commented 7 months ago

Until have evidence that lots of companies are using containers, I'm not inclined to put a ton of work into this. The ID and domains make sense if we can do it, but the other changes would be quite a bit of work.