27 Commits

Author SHA1 Message Date
Remco Burema
0b114876ef
Make this run from source again on Windows. 2021-09-01 16:56:47 +02:00
Konstantinos Karmas
d218b0bff9 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
2021-08-18 16:54:28 +02:00
Konstantinos Karmas
c5a956068f Fix mypy complaint
The `Keyring` is already imported from MacOS, so it's best to rename the fail on for Linux.

CURA-8490
2021-08-18 12:02:13 +02:00
Konstantinos Karmas
b1dc38f126 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
2021-08-18 11:57:09 +02:00
Konstantinos Karmas
7c8153eede Don't crash if the keyring password cannot be decoded
Fixes Sentry issue CURA-2S0
2021-08-11 17:25:45 +02:00
Konstantinos Karmas
ceca0c417a Catch the KeyringLocked also when setting the token in the keyring
CURA-8332
2021-06-23 11:22:12 +02:00
Konstantinos Karmas
8ade68dbef Catch the KeyringLocked error instead of the MacOS specific
Turns out that when the KeychainDenied error is raised, it is being caught by the macOS keyring api and the non-macOS-specific KeyringLocked error is raised instead, so we need to catch this one.

CURA-8332
2021-06-23 11:20:35 +02:00
Konstantinos Karmas
f62a403f28 Really fix the mypy issue
Hopefully

CURA-8332
2021-06-21 17:20:36 +02:00
Konstantinos Karmas
4a8b5ae61e Fix mypy issue
CURA-8332
2021-06-21 17:07:36 +02:00
Konstantinos Karmas
9fd0ac333e Don't check against generic exception
Define the KeychainDenied exception locally in non-Mac operating systems.

CURA-8332
2021-06-21 16:47:47 +02:00
Konstantinos Karmas
7785142831 Log info instead of exception when keyring is denied on Mac
CURA-8332
2021-06-21 16:14:48 +02:00
Konstantinos Karmas
c3782c9468 Check for KeychainDenied Exception only on OSX
CURA-8332
2021-06-21 15:40:18 +02:00
Konstantinos Karmas
951c656096 Import they KeychainDenied exception only on Mac
CURA-8332
2021-06-21 10:55:22 +02:00
Konstantinos Karmas
c1618565ea Don't crash if keyring access is denied on MacOS
CURA-8332
2021-06-21 10:47:53 +02:00
Kostas Karmas
07594f17a7 Fix setting empty auth tokens in the keyring on startup
When Cura is starting up, it reads the authentication data from the preferences (cura.cfg). If
the auth tokens have previously been stored in the keyring, it means that their values will be null
in the cura.cfg file. Therefore, on startup, Cura reads the tokens as none from the preferences and
then sets the empty values in the keyring as tokens. This leads to the user being signed off every
time Cura restarts on Mac.

On Windows, the access token was still stored in the preferences, so on startup it was safe. The
refresh token, on the other hand, had the same issue as on Mac, which means that on startup it was
read as None from the cura.cfg and was stored in the keyring as an empty string. This meant that,
even though on startup (on windows) the user was kept signed in, the next time Cura was attempting
to refresh the access token (after 7-8 minutes), it wouldn't be able, since its refresh token was
read as "" from the keyring. Also, if the user would close Cura and reopen it after 10 minutes
(so after the access token had expired) then they would be signed off on windows too.

This commit fixes that by making sure that if the given value of the refresh and access tokens are
empty, then they will not be stored in the keyring.

CURA-8178
2021-04-16 17:05:08 +02:00
Konstantinos Karmas
fe2d554ec0
Change the OS_X keyring backend module to macOS
Since the OS_X has been deprecated since keyring v22.0.0 and has been replaced by the macOS.

CURA-7180
2021-04-09 17:14:32 +02:00
Remco Burema
1c806199a4
Explicitly give keyring backend on Mac too.
CURA-7180
2021-04-08 14:08:35 +02:00
jelle Spijker
4b1087a138
Put BaseModel in quotes
Contributes to CURA-7180
2021-04-07 11:25:39 +02:00
jelle Spijker
33a812d696
Added typing fof KeyringAttributes
This should hopefully shut mypy up.

Contributes to CURA-7180
2021-04-07 11:06:06 +02:00
jelle Spijker
23ba1745a4
Handle storing None values in keyring
Write an empty string as value to the keyring if None is parsed and
return a None value if an empty string was parsed from the keyring.

CURA-7180_keyring_none_value
2021-04-04 12:27:43 +02:00
Remco Burema
e1490a68df
Also need to import this.
CURA-7180
2021-03-30 21:46:19 +02:00
Remco Burema
72248d47e1
Windows workaround for keyring issue.
So there is an issue with keyring w.r.t. frozen installs (maybe also local). If you have pywin32 installed, it works fine locally. Take a note here, that a variant of this package, pywin32-ctypes, a rudimentary version of that package that works wholly within python, is already installed as its a dependency for keyring on windows. Due to an unknown reason, when running it fails to detect this, so some workaround is needed, _or_ the 'normal' pywin32 package should be installed. However, problems occurred when attempts where made to install pywin32 via cx_freeze. Then the actual workaround was encountered (https://github.com/jaraco/keyring/issues/468), which _should_ hopefully let use use the keyring on windows without needing the 'full' version of pywin32.

CURA-7180
2021-03-30 20:40:33 +02:00
Remco Burema
bde88d7875
Don't store cerain keys ever.
CURA-7180
2021-03-30 17:24:25 +02:00
Kostas Karmas
fb5d59db32 Fix comment
The Windows Credential Manager actually fails if the password is more than 1024 bits long.

CURA-7180
2021-03-29 17:03:09 +02:00
Kostas Karmas
dbb15b7c71 Account for exception occured when storing long tokens on Windows
The Windows Credential Manager allows for up to 256bits passwords. If a password longer than that
is attempted to be written, it will throw a BaseException.

CURA-7180
2021-03-29 16:33:59 +02:00
Jelle Spijker
c462b62edc
Handle raised error when there is no keyring backend present
CURA-7180 keyring storage
2021-03-17 09:22:24 +01:00
Jelle Spijker
f51c466155
Use a descriptor to optionally store to Keyring
CURA-7180 keyring storage
2021-03-17 06:16:01 +01:00