user.js icon indicating copy to clipboard operation
user.js copied to clipboard

How to persist login using containers

Open spike-hue opened this issue 3 years ago • 10 comments

Hi, new here!

I'm using Firefox's Multi-Account Container extension (https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/). I have a container called Twitter Personal to sign into my personal Twitter account. I want this login within the container persisted when Firefox is closed. However, any other cookies/logins I want deleted.

Note:

  • To setup arkenfox, I followed this guide: https://12bytes.org/articles/tech/firefox/the-firefox-privacy-guide-for-dummies/.
  • My user-overrides.js file is copied from here: https://codeberg.org/12bytes.org/firefox-user.js-supplement/src/branch/master/user-overrides.js

Any suggestions to set in the user-overrides.js file to allow this to happen?

spike-hue avatar Sep 17 '22 18:09 spike-hue

#1543

rusty-snake avatar Sep 17 '22 18:09 rusty-snake

Thanks for response!

I just tried this and it does not work:

user_pref("permissions.isolateBy.userContext", true);

I tried adding this to my preexisting user-overrides.js file but did not work.

Then to start from clean slate, my entire user-overrides.js file now just contains and still doesn't work:

user_pref("permissions.isolateBy.userContext", true);

spike-hue avatar Sep 17 '22 18:09 spike-hue

Die you just add it to user-overrides.js or did you anything more (updater, restart, ...)?

Did you added the exception with ctrl-i?

rusty-snake avatar Sep 17 '22 18:09 rusty-snake

Here are the steps I took:

  1. Quit Firefox
  2. Deleted everything in user-overrides.js
  3. Added user_pref("permissions.isolateBy.userContext", true);. I did this by copying/pasting from https://codeberg.org/rusty-snake/firefox-config/src/commit/ea079491d22113843d61b3d93455518cdd00abad/assets/user-overrides.js#L25-L26. I am using Visual Studio Code which is plain text so no italicize.
  4. I ran ./updater.sh
  5. I ran ./prefsCleaner.sh
  6. Opened Firefox -> opened a custom container -> signed into Twitter -> Quit Firefox -> Opened Firefox -> Opened custom container and Twitter is logged out

Note:

  • not sure what you mean by ctrl-i
  • I am using the GUI to setup containers with https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/

spike-hue avatar Sep 17 '22 18:09 spike-hue

You need to add an cookie exception.

https://github.com/arkenfox/user.js/blob/3f09afdee07c5aea33f6dc4194e1425d6400a0d7/user.js#L768-L778

edit: https://github.com/arkenfox/user.js/wiki/3.2-Overrides-%5BCommon%5D#-keep-logins

rusty-snake avatar Sep 17 '22 18:09 rusty-snake

Ah I think it works now! So just to outline what I did:

  1. For clean slate, deleted everything and just added user_pref("permissions.isolateBy.userContext", true) to user-overrides.js
  2. Run ./updater.sh and then ./prefsCleaner.sh
  3. Go to ☰ Settings > Privacy & Security > Cookies & Site Data > Manage Exceptions
  4. Enter https://www.google.com (or Twitter, etc)
  5. Create a container using https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/
  6. Signin to Google within custom container
  7. Quit Firefox -> Reopen Firefox -> Go to container and should be logged into Google

I have one other question for this:

  • Since I allowed https://www.google.com cookies, will these be deleted in every tab after quitting Firefox? I would like them to be deleted except for the custom container. Please let me know if need other setting in user-overrides.js to do this if necessary? Seems like cookies persist

spike-hue avatar Sep 17 '22 19:09 spike-hue

@rusty-snake I don't use containers

two questions

  • without the pref, are exceptions not kept?
    • i.e containers are not treated as a different origin
    • e.g. if I always open abc.com in a set container and exempt it, then it just works? yes?
  • with the pref, do you need to add a contextId
    • e.g. if you have two containers for two gmail accounts

Perhaps we should add permissions.isolateBy.userContext to the user.js (and mod the wiki) with some info

Thorin-Oakenpants avatar Sep 18 '22 05:09 Thorin-Oakenpants

Sorry I don't get your question.

What I found out yet by testing in my Nightly

  • containers always isolate cookies, exceptions do not stop this (tested by changeing theme on DDG)
  • Permissions are bound to a container and get a ^userContextId=
    • e.g. block camera in one container (via ctrl-i), same site in other container will show camera prompt.
  • New to me: cookie/storageAccessAPI permissions are special (since when?) and shared between all containers (sAA have an ^userContextId= but is implicitly propagated into/out-of containers)

rusty-snake avatar Sep 18 '22 16:09 rusty-snake

Sorry I don't get your question.

you're the one telling users to add a pref - the least you could do is explain it

Thorin-Oakenpants avatar Sep 19 '22 03:09 Thorin-Oakenpants

Sorry I don't get your question.

What I found out yet by testing in my Nightly

  • containers always isolate cookies, exceptions do not stop this (tested by changeing theme on DDG)

  • Permissions are bound to a container and get a ^userContextId=

    • e.g. block camera in one container (via ctrl-i), same site in other container will show camera prompt.
  • New to me: cookie/storageAccessAPI permissions are special (since when?) and shared between all containers (sAA have an ^userContextId= but is implicitly propagated into/out-of containers)

Same behaviour here on stable. Camera and microphone (and I assume other permissions too) get a UserContextId when setting the permission when the pref is flipped. Cookie perms don't get a ContextId tho, could be a bug as I'm pretty sure it's supposed to behave like other perms as well.

1Naim avatar Sep 19 '22 22:09 1Naim

closing after 25 days - if there is a need or want to add permissions.isolateBy.userContext and document it, or there is a need to know how to persist logins per container (doesn't it just work?) then feel free to re-open and explain it

Thorin-Oakenpants avatar Oct 13 '22 02:10 Thorin-Oakenpants