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

use electron safeStorage #3676

Closed
ganthern opened this issue Nov 16, 2021 · 8 comments · Fixed by #6185 or #6360
Closed

use electron safeStorage #3676

ganthern opened this issue Nov 16, 2021 · 8 comments · Fixed by #6185 or #6360
Labels
desktop Desktop client related issues improvement nice-to-haves that are not impeding usage of any features state:tested We tested it and are about to release it
Milestone

Comments

@ganthern
Copy link
Contributor

ganthern commented Nov 16, 2021

once #3658 lands, we could use the new safeStorage API to encrypt the device key and store it in a file.

This would offload the device key management to electron and make our direct keytar dependency obsolete.

@ganthern ganthern added improvement nice-to-haves that are not impeding usage of any features desktop Desktop client related issues labels Nov 16, 2021
@ganthern ganthern self-assigned this Dec 14, 2021
@bedhub bedhub added this to the Next release milestone Dec 14, 2021
ganthern added a commit that referenced this issue Dec 16, 2021
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
@ganthern
Copy link
Contributor Author

ganthern commented Dec 16, 2021

Testing

  • previously set alarms get rescheduled even when offline after the app is restarted
  • the app, if saved credentials are present, uses the same sseinfo after the update (terminal output doesn't say anything about sseInfo corrupted or not present)

@ganthern
Copy link
Contributor Author

safeStorage passes through a Chromium API and that doesn't get initialized until a BrowserWindow gets created:
electron/electron#32206

ganthern added a commit that referenced this issue Dec 21, 2021
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Jan 6, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
@charlag
Copy link
Contributor

charlag commented Jan 19, 2022

We decided to not user Chromium APIs because they are coupled to window pretty tightly and we have no control over it
see #3733

@charlag charlag closed this as completed Jan 19, 2022
@charlag charlag removed this from the Next release milestone Jan 19, 2022
@charlag charlag added the state:wontfix issues that are not significant enough to invest in or that are intended behaviour label Jan 19, 2022
ganthern added a commit that referenced this issue Feb 24, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Mar 1, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Mar 3, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Mar 10, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Mar 15, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Mar 22, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Mar 24, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue Apr 26, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
ganthern added a commit that referenced this issue May 4, 2022
* renames PathUtils.swapFilename to replaceLastComponent
* provides a new impl for SecretStorage
* uses electron.safeStorage to encrypt the device key that then gets
stored in a file in app.getPath('userData')/safe_storage/
* from now on, per-user data is encrypted with a per-user key,
even for per-machine installs.

#3733
close #3676
@ganthern ganthern removed their assignment Aug 16, 2023
@ganthern ganthern removed the state:wontfix issues that are not significant enough to invest in or that are intended behaviour label Nov 23, 2023
@ganthern ganthern reopened this Nov 23, 2023
@charlag
Copy link
Contributor

charlag commented Nov 23, 2023

Some points to check:

  • Does it handle cancellation?
  • How does it handle failed authentication?
  • When does it prompt the user?
  • Does it work with freedesktop portal/flatpak?
  • do we need to select backend explicitly for linux? Does it allow us to get rid of "secret storage" requirement on linux?

@ganthern
Copy link
Contributor Author

ganthern commented Nov 23, 2023

MacOS:

  • cancellation is handled in the usual way (we get the key, it fails, we show an error dialog with a link to the FAQ)
  • wrong passwords just cause the dialog to stay until it's cancelled or the correct password is entered.
  • user is prompted on startup for each key the app did not create itself. at most 3 times - safe storage key, tutanota-vault, tutanota-credentials. The latter two are only requested because we want to migrate them. This could be reduced by only doing the migration once, currently it's unconditional.

Linux (GNOME/Seahorse/libsecret):

Windows:

  • seems to just work, could not get it to ask for any confirmation?

@ganthern ganthern linked a pull request Nov 24, 2023 that will close this issue
@ganthern
Copy link
Contributor Author

ganthern commented Nov 24, 2023

I'm unsure how to test this for flatpak. we can easily make a test build (or several) once it's released, but the build process expects the prebuilt client to be on github. Not sure where to put test builds for it to pick up.

maybe attach it to an old release and hardcode the URL? Is there a way to build this locally?

E: flatpak-builder apparently

@charlag
Copy link
Contributor

charlag commented Nov 24, 2023

yeah I'd try just using flatpak builder

@ganthern
Copy link
Contributor Author

It just works and defaults to gnome-libsecret backend if we just update tutanota to use safeStorage. Still needs libsecret.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop Desktop client related issues improvement nice-to-haves that are not impeding usage of any features state:tested We tested it and are about to release it
Projects
None yet
5 participants