145 Commits

Author SHA1 Message Date
Jaime van Kessel
6dc65a4912 Fix crash with login
Fixes CURA-2N2
2021-10-01 13:43:33 +02:00
luz paz
d68f375e38 Fix various typos
Found via `codespell -q 3 -S *.po,*.pot -L childs,initialy,lod,ned,te,slicable,sur,tutoriels,wont`
2021-09-07 11:33:54 -04:00
Jaime van Kessel
8b5cfc9c28 Use token_hex from secrets instead of choice
CURA-8401
2021-09-03 09:57:04 +02:00
Jaime van Kessel
e24a844d17 Use secrets instead of random
Since we're no longer stuck on python 3.5, we can use secrets instead of random
which provides better randomness.

CURA-8401
SEC-207
2021-09-02 14:25:57 +02:00
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
e5856bf6bc Log the connection error message produced by the request 2021-08-17 15:52:12 +02:00
Jaime van Kessel
1f523053d9 Add even more logging to authorization service 2021-08-12 15:35:14 +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
5bf24ed678 Add campaign tags to the logoff link
CURA-8441
2021-08-09 11:56:41 +02:00
Jaime van Kessel
57e66a5796 Add campaign links
CURA-8441
2021-08-05 15:42:23 +02:00
Jelle Spijker
2263969d5f
Updated message with message types
Contributes to CURA-8418
2021-07-28 08:45:42 +02:00
Jaime van Kessel
900db57f0f
Update messages to use the message_types
CURA-8418
2021-07-27 11:54:43 +02:00
Jaime van Kessel
b7ee3298c2
Add extra logging to auth server 2021-07-23 10:40:30 +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
Ghostkeeper
e60e44b919
Interpret timeouts as general connection errors
It's a similar problem for us.
We should really have used the HttpRequestManager for these things.

Fixes Sentry issue CURA-295.
2021-06-07 15:03:46 +02:00
fieldOfView
be06108f36 Fix an crash when starting Cura without a network connection 2021-05-24 18:43:05 +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
387fc36dc6
Small aesthetic code changes
CURA-7180 keyring storage
2021-03-17 09:30:31 +01: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
b6b9dd1864
Fixed wrong typing
CURA-7180 keyring storage
2021-03-17 07:34:28 +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
Jelle Spijker
d06a25595a
Use a descriptor to optionally store to Keyring
CURA-7180 keyring storage
2021-03-16 19:28:56 +01:00
Jelle Spijker
6372fbed54
Added copyright notice
CURA-7180 keyring storage
2021-03-16 11:57:58 +01:00
Jelle Spijker
96e39810f2
Sync after log in works again
Needed to restore the access token after the
auth data was written to the preference file.

CURA-7180 keyring storage
2021-03-15 14:35:00 +01:00
Jelle Spijker
fcf698f00b
Added documentation and refactored
CURA-7180 keyring storage
2021-03-15 14:16:27 +01:00
Jelle Spijker
2796b9bef3
Store new keys to preference
CURA-7180 keyring storage
2021-03-15 13:06:42 +01:00
Jelle Spijker
b604bbd255
Store secrets as securely as possible
Use the keyring if allowed, available, otherwise use preference

CURA-7180 keyring storage
2021-03-15 11:48:42 +01:00
Jelle Spijker
47df060bee
Added fundaments of SecretStorage vault
This class will handle the storing and processing
of secrets. Such as tokens. It will try to use the system
keyring by default. Falling back to less secure methods,
if the user doesn't allow access to the keyring or if
the back-end is unsupported.

CURA-7180 keyring storage
2021-03-11 14:21:51 +01:00
Jelle Spijker
720b356221
Merge remote-tracking branch 'origin/master' into CURA-7180_keyring_storage 2021-03-08 15:23:46 +01:00