From b1dc38f126f9a483257d85f8b79238908657d58a Mon Sep 17 00:00:00 2001 From: Konstantinos Karmas Date: Wed, 18 Aug 2021 11:57:09 +0200 Subject: [PATCH 1/3] Don't load a keyring backend on Linux We do not support it on Linux and it can cause problems if there is a system keyring configured. CURA-8490 --- cura/OAuth2/KeyringAttribute.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cura/OAuth2/KeyringAttribute.py b/cura/OAuth2/KeyringAttribute.py index b8864e31e0..7d399077f5 100644 --- a/cura/OAuth2/KeyringAttribute.py +++ b/cura/OAuth2/KeyringAttribute.py @@ -21,6 +21,10 @@ if Platform.isWindows() and hasattr(sys, "frozen"): if Platform.isOSX() and hasattr(sys, "frozen"): from keyring.backends.macOS import Keyring keyring.set_keyring(Keyring()) +if Platform.isLinux() and hasattr(sys, "frozen"): + # We do not support the keyring on Linux, so make sure no Keyring backend is loaded, even if there is a system one. + from keyring.backends.fail import Keyring + keyring.set_keyring(Keyring()) # Even if errors happen, we don't want this stored locally: DONT_EVER_STORE_LOCALLY: List[str] = ["refresh_token"] From c5a956068f7cac7604279dfe2f4e275e1cc5af89 Mon Sep 17 00:00:00 2001 From: Konstantinos Karmas Date: Wed, 18 Aug 2021 12:02:13 +0200 Subject: [PATCH 2/3] Fix mypy complaint The `Keyring` is already imported from MacOS, so it's best to rename the fail on for Linux. CURA-8490 --- cura/OAuth2/KeyringAttribute.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/OAuth2/KeyringAttribute.py b/cura/OAuth2/KeyringAttribute.py index 7d399077f5..70d445d921 100644 --- a/cura/OAuth2/KeyringAttribute.py +++ b/cura/OAuth2/KeyringAttribute.py @@ -23,8 +23,8 @@ if Platform.isOSX() and hasattr(sys, "frozen"): keyring.set_keyring(Keyring()) if Platform.isLinux() and hasattr(sys, "frozen"): # We do not support the keyring on Linux, so make sure no Keyring backend is loaded, even if there is a system one. - from keyring.backends.fail import Keyring - keyring.set_keyring(Keyring()) + from keyring.backends.fail import Keyring as NoKeyringBackend + keyring.set_keyring(NoKeyringBackend()) # Even if errors happen, we don't want this stored locally: DONT_EVER_STORE_LOCALLY: List[str] = ["refresh_token"] From d218b0bff99da1cff460e87d8e5dc55ae7b29e9f Mon Sep 17 00:00:00 2001 From: Konstantinos Karmas Date: Wed, 18 Aug 2021 16:54:28 +0200 Subject: [PATCH 3/3] Remove check for "frozen" when setting the keyring backend There is no need to have a different behavior from source compared to frozen builds when it comes to the keyring. CURA-8490 --- cura/OAuth2/KeyringAttribute.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/OAuth2/KeyringAttribute.py b/cura/OAuth2/KeyringAttribute.py index 70d445d921..2aff74d031 100644 --- a/cura/OAuth2/KeyringAttribute.py +++ b/cura/OAuth2/KeyringAttribute.py @@ -14,14 +14,14 @@ if TYPE_CHECKING: # Need to do some extra workarounds on windows: import sys from UM.Platform import Platform -if Platform.isWindows() and hasattr(sys, "frozen"): +if Platform.isWindows(): import win32timezone from keyring.backends.Windows import WinVaultKeyring keyring.set_keyring(WinVaultKeyring()) -if Platform.isOSX() and hasattr(sys, "frozen"): +if Platform.isOSX(): from keyring.backends.macOS import Keyring keyring.set_keyring(Keyring()) -if Platform.isLinux() and hasattr(sys, "frozen"): +if Platform.isLinux(): # We do not support the keyring on Linux, so make sure no Keyring backend is loaded, even if there is a system one. from keyring.backends.fail import Keyring as NoKeyringBackend keyring.set_keyring(NoKeyringBackend())