96 Commits

Author SHA1 Message Date
Remco Burema
831af362cb Constantify magic values.
part of CURA-11406
2024-02-14 15:46:40 +01:00
Remco Burema
fc0d1a54f3 Merge remote-tracking branch 'origin/main' into CURA-11406_fix_auth_refresh_after_sleep 2024-02-14 10:31:17 +01:00
Remco Burema
5bcc37d7d7 Revert "Change bool setting to more flexible callback function"
This reverts commit ff478559b0f169a0606fbb2e34429dc929130dcb.
2024-01-18 10:44:15 +01:00
Erwan MATHIEU
ff478559b0 Change bool setting to more flexible callback function 2024-01-17 19:51:28 +01:00
Erwan MATHIEU
330dfd8be0 Add retry to OAuth token refresh failure
CURA-11406
2024-01-10 15:13:42 +01:00
Erwan MATHIEU
b794989468 Allow for OAuth service to stop after token has been retrieved 2023-12-04 20:58:11 +01:00
Erwan MATHIEU
aac9af577b Fix AuthorizationService signals 2023-12-04 20:09:36 +01:00
jspijker
f76f711790 Update mentions to UltiMaker
Contributes to CURA-9808
2022-11-28 14:11:21 +01:00
Remco Burema
abe7c1bf7f
Search/replace Qt5->Qt6.
part of upgrading Qt to v6.2: CURA-8591
2021-12-28 14:46:02 +01:00
Jelle Spijker
36e28a245c
Fixed typing issues
Contributes to: CURA-8539
2021-11-23 13:56:04 +01:00
Jelle Spijker
0a43366ffc
Fixed some styling and typing issues
Some boyscouting.
Contributes to: CURA-8539
2021-11-23 11:10:22 +01:00
Jelle Spijker
70504f1b04
Modernize typing usage
Some boyscouting.
2021-11-23 11:10:22 +01:00
Ghostkeeper
3f92b46ac8
Don't restart refresh token while it's already processing
If two requests to the API occur at the same time, they will both see at the same time that they need an access token, and if it is expired they will both see that it needs refreshing. The server then sees two refreshes, both with the same refresh token. This is not allowed. The second one then gets a failure to refresh the token, which causes the user to log out.
Instead, we'll stop one of the refresh requests. They were fire-and-forget anyway, so it's not needed to actually continue the request.

Contributes to issue CURA-8539.
2021-11-22 18:52:43 +01:00
Ghostkeeper
8ea8cc752f
Also call processing functions for error callbacks
Otherwise the appropriate callbacks might not get called.

Contributes to issue CURA-8539.
2021-11-22 14:44:52 +01:00
Ghostkeeper
937d48a4e8
Add missing failed_callback
If it fails to check the token, respond through the callback with None as well.

Contributes to issue CURA-8539.
2021-11-22 13:24:06 +01:00
Ghostkeeper
30d19844f2
Always callback if there is a callback, even if no auth data
Because not having auth data is a reason to return no profile too. Otherwise the other side might wait for a response for a long time.

Contributes to issue CURA-8539.
2021-11-22 10:45:01 +01:00
Ghostkeeper
1636cca601
Add missing return
We're calling back that there is no auth data, so we should stop here and not try to obtain a user profile.

Contributes to issue CURA-8539.
2021-11-22 10:34:39 +01:00
Ghostkeeper
9895015235
Call getAccessTokenUsingRefreshToken asynchronously
Getting into nested inline functions into inline functions here. Let's see what the reviewer thinks of all this!

Contributes to issue CURA-8539.
2021-11-19 17:04:37 +01:00
Ghostkeeper
7091c5f3aa
Make getAuthenticationTokenUsingXYZ asynchronous
As a result, the local webserver now needs to synchronise that with a lock. Otherwise the do_GET function would no longer block, and wouldn't properly be able to return the correct redirect URL.

Contributes to issue CURA-8539.
2021-11-19 16:55:45 +01:00
Ghostkeeper
9b55ae6dda
Remove unused imports of requests
This was the objective, really.

Contributes to issue CURA-8539.
2021-11-19 16:25:50 +01:00
Ghostkeeper
acbbf83510
Deal with absence of callback function
It may be None, so then we don't need to call back. The consumer may just take it from self._user_profile.

Contributes to issue CURA-8539.
2021-11-19 16:23:48 +01:00
Ghostkeeper
bfb8440a04
Get user profile asynchronously when restoring from preferences
Do not stop the start-up process for it. Let the callback handle the updating if necessary.

Contributes to issue CURA-8539.
2021-11-19 16:20:00 +01:00
Ghostkeeper
591a2f89b8
Make getUserProfile return profile asynchronously
All via callbacks. Quite a mess.

Contributes to issue CURA-8539.
2021-11-19 15:29:29 +01:00
Ghostkeeper
920d9b9d44
Make _parseJWT asynchronous as well
Now it calls checkToken correctly. However now this _parseJWT is not called correctly since there are things calling this one in an attempt to be synchronous again.
There is the additional issue that we can't call getAccessTokenUsingRefreshToken synchronously now, because this runs on the main thread and it will then block the main thread until the request is made, which is never because the request is also done on the main thread via Qt's event loop.

Contributes to issue CURA-8539.
2021-11-18 17:33:39 +01:00
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
2c2e7f2c16 Add even more logging to authorization service 2021-08-11 10:19:27 +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
fieldOfView
be06108f36 Fix an crash when starting Cura without a network connection 2021-05-24 18:43:05 +02:00
Jelle Spijker
387fc36dc6
Small aesthetic code changes
CURA-7180 keyring storage
2021-03-17 09:30:31 +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
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
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
Jaime van Kessel
f85cad37cf
Expand the logging for the auth data a bit more
We're getting some reports that people are suddenly logged out. The working
theory is that they are mixing staging & production builds. This logging
should tell us enough to find out if that is the case!
2021-01-28 10:31:47 +01:00
Ghostkeeper
4380cdbd86
Don't crash on malformed JSON structures
JSON dictionaries need to have a certain structure such as strings as keys. If that's not correct it gives a TypeError. Don't crash on those; give a similar error message as when the values in the JSON are invalid.
2021-01-19 16:31:31 +01:00
Remco Burema
a25a51eddb
Windows workaround for OAuth data removal from config.
Windows won't allow long keys in the backend the keyring python package uses as a backend. This means the access_token part can't be stored in the obvious way. Timeboxed some attempts at working around this limitation, but couldn't make it work within the time set. As this is mostly an extra precaustion protecting users that share config folders around against themselves (in other words, if this goes wrong it's not unreasonable to blame the user) it's not top critical, and the important part of that (the refresh_token) can proceed, giving any potential attacker only a 10 minute window from the moment any user shares their %appdata%/cura files (again, this is not how we intent for users to behave, but they can and will do it this way).

CURA-7180
2020-12-24 14:39:22 +01:00
Jaime van Kessel
bff3ba577b
Store auth & refresh key in keyring instead of in preferences
People tend to share configuration folders, which just isn't secure.

CURA-7180
2020-12-21 14:02:45 +01:00
Nino van Hooff
89f0970a88 Remove trailing whitespace from Python files 2020-05-29 14:30:33 +02:00
Nino van Hooff
8e347c1034 Merge remote-tracking branch 'origin/doxygen_to_restructuredtext_comments' into doxygen_to_restructuredtext_comments
# Conflicts:
#	cura/OAuth2/AuthorizationService.py
2020-05-15 13:40:22 +02:00
Kostas Karmas
898ca852f0 Fix mypy complaint about Optional type
CURA-7427
2020-05-12 13:40:27 +02:00
Kostas Karmas
32efb8d7bb Fix description comment of _generate_auth_url()
CURA-7427
2020-05-12 13:17:18 +02:00
Kostas Karmas
d3fb002d9b Transfer the generation of the auth link into its own function
The authentication link should be prepended with a logoff link from
mycloud, if it is requested. In order to make this process testable
this commit separates the generation of the authentication link,
based on whether it requests for a browser logoff first, into its
own function.

This commit also adds tests for this function.

CURA-7427
2020-05-12 13:07:39 +02:00
Kostas Karmas
b717755f20 Add "Sign in with another account" button in AddCloudPrintersView
There are cases where Cura and the browser fall out of sync when it
comes to accounts. In such cases, you may be logged in cura with an
account that has no cloud printers and in the browser with an account
that has printers. So when you press the "Add cloud printer" button,
you are redirected to mycloud and you see cloud printers that are not
detected by Cura (because Cura is in a different acconut). In such
cases, the user can now press the "Sign in with a different account"
link in the "Waiting for cloud response" page, which will log him/her
out in Cura AND in the browser, and then reinitiate the whole
authorization flow, to make sure the accounts are in sync.

CURA-7427
2020-05-11 17:47:09 +02:00
jelle Spijker
b032101e55
Updated comments in cura/OAuth2
Used DOX_2_RST.py to convert doxygen style comments to sphinx style comments
2020-05-11 13:16:29 +02:00
Nino van Hooff
ea00ff3c47 Update wording for authorization server error message
CURA-7346
2020-04-09 16:59:43 +02:00