ImFusion C++ SDK 4.5.0
ImFusion::LabelsAuthorizationProvider Class Reference

#include <ImFusionLabels/lib/include/ImFusion/Labels/Core/LabelsAuthorizationProvider.h>

Provides authorization for the remote project as well as DICOMweb and other web resources. More...

Inheritance diagram for ImFusion::LabelsAuthorizationProvider:

Detailed Description

Provides authorization for the remote project as well as DICOMweb and other web resources.

It automatically fetches a potential Keycloak configuration. Each server can have its own authorization flows. Those are discovered automatically for the Labels remote server. For all other servers, Basic auth is assumed.

Classes

struct  OIDCConfig

Public Member Functions

 LabelsAuthorizationProvider (const std::string &projectUrl, std::optional< OIDCConfig > oidcConfig)
bool refreshAuthorization (const Filesystem::Url &url, int numFailedRequests) override
 Try to refresh the authorization without user interaction.
void addOAuth2DeviceFlow (const Filesystem::Url &url, Network::OAuth2::DeviceFlowConfig config)
void addOAuth2AuthCodeFlow (const Filesystem::Url &url, Network::OAuth2::AuthorizationCodeFlowConfig config)
void addOAuth2PasswordFlow (const Filesystem::Url &url, Network::OAuth2::PasswordFlowConfig config)
void addOAuth2AuthCodeFlow (Network::OAuth2::AuthorizationCodeFlowConfig config)
void addOAuth2DeviceFlow (Network::OAuth2::DeviceFlowConfig config)
Public Member Functions inherited from ImFusion::QtAuthorizationProvider
std::optional< Network::AccessTokenaccessToken (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.

Static Public Member Functions

static std::shared_ptr< LabelsAuthorizationProvider > acquireProjectAuthorization (const Filesystem::Url &serverUrl, QWidget *parent)
 Tries to get a KeycloakConfig from the given server and shows a login dialog.
static std::optional< OIDCConfiggetOIDCConfig (const std::string &serverUrl)
 Gets the keycloak configuration from a Labels server.

Additional Inherited Members

Protected Types inherited from ImFusion::QtAuthorizationProvider
using ServerUrl = std::string
Protected Attributes inherited from ImFusion::QtAuthorizationProvider
QWidget * m_parent = nullptr
std::shared_mutex m_serverAuthorizationsMutex
std::unordered_map< ServerUrl, Network::AccessTokenm_serverAuthorizations
bool m_useBasicAuth = false
std::optional< Network::OAuth2::DeviceFlowConfigm_useOAuth2DeviceFlow
std::optional< Network::OAuth2::AuthorizationCodeFlowConfigm_useOAuth2AuthCodeFlow
std::optional< Network::OAuth2::PasswordFlowConfigm_useOAuth2PasswordFlow

Member Function Documentation

◆ acquireProjectAuthorization()

std::shared_ptr< LabelsAuthorizationProvider > ImFusion::LabelsAuthorizationProvider::acquireProjectAuthorization ( const Filesystem::Url & serverUrl,
QWidget * parent )
static

Tries to get a KeycloakConfig from the given server and shows a login dialog.

Returns nullptr if the user did not login successfully.

◆ refreshAuthorization()

bool ImFusion::LabelsAuthorizationProvider::refreshAuthorization ( const Filesystem::Url & url,
int numFailedRequests )
overridevirtual

Try to refresh the authorization without user interaction.

Implementations should stop retrying after a certain number of failed attempts. This method will be called from multiple threads. If an auth scheme does not support refreshing without user interaction, implementations should return false after the first failed attempt.

Implementations that cache authorization according to the url, should remove entries from the cache that cannot be refreshed after one failed request.

This method can also be called without a previously failed request (numFailedRequests == 0) in case the token should be refreshed before it expires.

E.g. if this method fails, the authorization method should return an empty string until acquireAuthorization was called again.

Implements ImFusion::Network::AuthorizationProvider.

◆ addOAuth2AuthCodeFlow()

◆ addOAuth2DeviceFlow()


The documentation for this class was generated from the following file:
  • ImFusionLabels/lib/include/ImFusion/Labels/Core/LabelsAuthorizationProvider.h
Search Tab / S to search, Esc to close