170 Commits

Author SHA1 Message Date
Remco Burema
abe7c1bf7f
Search/replace Qt5->Qt6.
part of upgrading Qt to v6.2: CURA-8591
2021-12-28 14:46:02 +01:00
Ghostkeeper
006b5e25b2
Also catch unknown keyring errors
We're confident now that we get it to not crash for most normal cases. If there is a crash here it's due to the internals of Keyring. We're catching all of the others separately anyway.

Fixes Sentry issue CURA-340.
2021-12-13 11:22:37 +01:00
Ghostkeeper
5da63fda26
Also catch BlockingIOError when getting a keyring attribute
This occurs when there's a timeout, on some systems, when asking for the password to the keyring. We'll interpret a timeout as a refusal to enter a password.

Fixes Sentry issue CURA-332.
2021-11-30 13:27:32 +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
1ee9f73075
Only call success_callback if it's not None
It could also be called as a fire-and-forget update thing.

Contributes to issue CURA-8539.
2021-11-22 16:20:37 +01:00
Ghostkeeper
595a6580f5
Use error callback and with correct number of parameters
It gives two parameters, additionally an error code. However our callback wrapper gets the error code from the reply itself so it doesn't need it.

Contributes to issue CURA-8539.
2021-11-22 16:17:30 +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
c36863da56
Only call failed_callback if provided
Otherwise we'd crash because NoneType can't be called.

Contributes to issue CURA-8539.
2021-11-22 11:59:23 +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
ffb891fb69
Fix call to failed_callback
It provides 2 arguments (reply and error) which we both ignore and proceed to call failed_callback. And failed_callback may also be None in which case we don't call anything.

Contributes to issue CURA-8539.
2021-11-19 17:09:33 +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
Ghostkeeper
aff0764c1d
Add failed callback for when the request fails
Maybe we should add a parameter to this to respond with an error message. But maybe later.

Contributes to issue CURA-8539.
2021-11-18 17:19:05 +01:00
Ghostkeeper
a9990eaa75
Make parseJWT asynchronous
This involves returning the user profile via a callback.
No longer use the Requests library, which doesn't properly use the SSL certificates locally on the computer like the QNetworkManager does.

Contributes to issue CURA-8539.
2021-11-18 17:11:27 +01:00
Ghostkeeper
f1c763ad9f
Use HttpRequestManager to acquire new tokens
This is a re-write from a previous attempt. Instead of requests, which doesn't properly use SSL certificates installed on the computer among other things, we'll now use the HttpRequestManager which uses QNetworkManager under the hood and properly uses system settings.
The QNetworkManager is asynchronous which would normally be very nice, but due to the nature of this call we want to make it synchronous so we'll use a lock here.

Contributes to issue CURA-8539.
2021-11-17 14:32:53 +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
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