![]() |
ImFusion C++ SDK 4.5.0
|
#include <ImFusion/GUI/QtAuthorizationProvider.h>
AuthorizationProvider that shows a Qt LoginDialog. More...
AuthorizationProvider that shows a Qt LoginDialog.
Public Member Functions | |
| std::optional< Network::AccessToken > | accessToken (const Filesystem::Url &url) const override |
| Like authorization, but returns the full AccessToken. | |
| std::string | authorization (const Filesystem::Url &url) const override |
| Get the Authorization header for the given url. | |
| bool | refreshAuthorization (const Filesystem::Url &url, int numFailedRequests) override |
| Tries to obtain a new access token if a refresh token is available. | |
| bool | acquireAuthorization (const Filesystem::Url &serverUrl, const std::string &message) override |
| Acquire authorization by e.g. | |
| void | removeAuthorization (const Filesystem::Url &url) override |
| Remove any cached authorization for the given server. | |
| void | addAuthorization (const Filesystem::Url &url, Network::AccessToken token) |
| Directly add an access token obtained through other means. | |
| void | addBasicAuthorization () |
| void | addOAuth2DeviceFlow (Network::OAuth2::DeviceFlowConfig config) |
| void | addOAuth2AuthCodeFlow (Network::OAuth2::AuthorizationCodeFlowConfig config) |
| void | addOAuth2PasswordFlow (Network::OAuth2::PasswordFlowConfig config) |
| void | setDialogParent (QWidget *parent) |
| Sets the parent that will be used for the LoginDialog. | |
| Public Member Functions inherited from ImFusion::Network::AuthorizationProvider | |
| Filesystem::Url | extractServerUrl (const Filesystem::Url &url) const |
| Extract the server part of the URL. | |
Protected Types | |
| using | ServerUrl = std::string |
Protected Member Functions | |
| virtual std::unique_ptr< Network::LoginDialog > | createDialog (const Filesystem::Url &serverUrl) const |
Protected Attributes | |
| QWidget * | m_parent = nullptr |
| std::shared_mutex | m_serverAuthorizationsMutex |
| std::unordered_map< ServerUrl, Network::AccessToken > | m_serverAuthorizations |
| bool | m_useBasicAuth = false |
| std::optional< Network::OAuth2::DeviceFlowConfig > | m_useOAuth2DeviceFlow |
| std::optional< Network::OAuth2::AuthorizationCodeFlowConfig > | m_useOAuth2AuthCodeFlow |
| std::optional< Network::OAuth2::PasswordFlowConfig > | m_useOAuth2PasswordFlow |
|
overridevirtual |
Like authorization, but returns the full AccessToken.
Reimplemented from ImFusion::Network::AuthorizationProvider.
|
overridevirtual |
Get the Authorization header for the given url.
The url is the complete url for the request that is going to be performed. Implementation should cache the value according to the server URL (see extractServerUrl). When an empty string is returned, no Authorization header should be send. This method will be called from multiple threads.
Implements ImFusion::Network::AuthorizationProvider.
|
overridevirtual |
Tries to obtain a new access token if a refresh token is available.
Note that this class does not regularly refresh token in the background before they expire.
Implements ImFusion::Network::AuthorizationProvider.
|
overridevirtual |
Acquire authorization by e.g.
asking the user.
This method might get called from another thread. In this case, implementations that require the main thread to show a GUI should just return false.
An optional message can be provided (e.g. to display an error from a previous login attempt).
Should return true if authorization could be acquired or false otherwise.
This method is not expected to check whether the acquired authorization actually works, because this is simply not possible with some auth schemes.
Code that requires authorization should call this method from the main thread before performing requests. If those requests fail with 401, this method should be called again from the main thread before retrying the requests. If multiple requests are run in parallel, it must be avoided to call this method multiple times simultaneous, because this might popup multiple dialogs.
Implements ImFusion::Network::AuthorizationProvider.
|
overridevirtual |
Remove any cached authorization for the given server.
This should essentially log out the user and let the user re-authenticate with the next acquireAuthorization call.
Implements ImFusion::Network::AuthorizationProvider.
| void ImFusion::QtAuthorizationProvider::addBasicAuthorization | ( | ) |
| void ImFusion::QtAuthorizationProvider::addOAuth2DeviceFlow | ( | Network::OAuth2::DeviceFlowConfig | config | ) |
| void ImFusion::QtAuthorizationProvider::addOAuth2AuthCodeFlow | ( | Network::OAuth2::AuthorizationCodeFlowConfig | config | ) |
| void ImFusion::QtAuthorizationProvider::addOAuth2PasswordFlow | ( | Network::OAuth2::PasswordFlowConfig | config | ) |