Class: QgsAuthMethod¶
Abstract base class for authentication method plugins.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clearCachedConfig()
, description()
, displayDescription()
, key()
, updateMethodConfig()
Class Hierarchy¶
Base classes¶
Abstract Methods
Clear any cached configuration. |
|
A non-translated short description representing the auth method for use in debug output and About dialog |
|
Translatable display version of the ' |
|
A non-translated short name representing the auth method |
|
Update an authentication configuration in place |
Methods
Sets list of data providers this auth method supports |
|
Sets the support expansions (points in providers where the authentication is injected) of the auth method |
|
Sets the version of the auth method (useful for future upgrading) |
|
The data providers that the method supports, allowing for filtering out authcfgs that are not applicable to a given provider, or where the updating code is not currently implemented. |
|
Flags that represent the update points (where authentication configurations are expanded) supported by an authentication method. |
|
Increment this if method is significantly updated, allow updater code to be written for previously stored authcfg |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsAuthMethod. See the FAQ for more details.
Constructs the configuration for the authentication method |
|
Update data source connection items with authentication components |
|
Update proxy settings with authentication components |
|
Update a network reply with authentication components |
|
Update a network request with authentication components |
Static Methods
Tag signifying that this is an authentcation method (e.g. for use as title in message log panel output). |
Attributes
- class qgis.core.QgsAuthMethod[source]¶
Bases:
QObject
- __init__()
Construct a default authentication method
Note
Non-public since this is an abstract base class
- All = 31¶
- DataSourceUri = 4¶
- class Expansion¶
Bases:
int
- class Expansions¶
- class Expansions(f: QgsAuthMethod.Expansions | QgsAuthMethod.Expansion)
- class Expansions(a0: QgsAuthMethod.Expansions)
Bases:
object
- GenericDataSourceUri = 8¶
- NetworkProxy = 22¶
- NetworkReply = 2¶
- NetworkRequest = 1¶
- static authMethodTag() str [source]¶
Tag signifying that this is an authentcation method (e.g. for use as title in message log panel output)
- Return type:
str
- abstract clearCachedConfig(self, authcfg: str | None)[source]¶
Clear any cached configuration. Called when the
QgsAuthManager
deletes an authentication configuration (authcfg).Note
It is highly recommended that a cache of authentication components (per requested authcfg) be implemented, to avoid excessive queries on the auth database. Such a cache could be as simple as a QHash or QMap of authcfg ->
QgsAuthMethodConfig
. See ‘Basic’ auth method plugin for example.- Parameters:
authcfg (Optional[str])
- abstract description(self) str [source]¶
A non-translated short description representing the auth method for use in debug output and About dialog
- Return type:
str
- abstract displayDescription(self) str [source]¶
Translatable display version of the ‘
description()
’- Return type:
str
- virtual editWidget(self, parent: QWidget | None) QWidget | None [source]¶
Constructs the configuration for the authentication method
Added in version 3.22.
- Parameters:
parent (Optional[QWidget])
- Return type:
Optional[QWidget]
- abstract key(self) str [source]¶
A non-translated short name representing the auth method
- Return type:
str
- setDataProviders(self, dataproviders: Iterable[str | None])[source]¶
Sets list of data providers this auth method supports
- Parameters:
dataproviders (Iterable[Optional[str]])
- setExpansions(self, expansions: QgsAuthMethod.Expansions | QgsAuthMethod.Expansion)[source]¶
Sets the support expansions (points in providers where the authentication is injected) of the auth method
- Parameters:
expansions (Union[QgsAuthMethod.Expansions, QgsAuthMethod.Expansion])
- setVersion(self, version: int)[source]¶
Sets the version of the auth method (useful for future upgrading)
- Parameters:
version (int)
- supportedDataProviders(self) List[str] [source]¶
The data providers that the method supports, allowing for filtering out authcfgs that are not applicable to a given provider, or where the updating code is not currently implemented.
- Return type:
List[str]
- supportedExpansions(self) QgsAuthMethod.Expansions [source]¶
Flags that represent the update points (where authentication configurations are expanded) supported by an authentication method.
Note
These should directly correlate to existing ‘update*()’ member functions
- Return type:
- virtual updateDataSourceUriItems(self, connectionItems: Iterable[str | None], authcfg: str | None, dataprovider: str | None = '') bool [source]¶
Update data source connection items with authentication components
- Parameters:
connectionItems (Iterable[Optional[str]]) – QStringlist of ‘key=value’ pairs, as utilized in
QgsDataSourceUri.connectionInfo()
authcfg (Optional[str]) – Authentication configuration ID
dataprovider (Optional[str] = '') – Textual key for a data provider, e.g. ‘postgres’, that allows for custom updater code specific to the provider
- Return type:
bool
- Returns:
Whether the update succeeded
- abstract updateMethodConfig(self, mconfig: QgsAuthMethodConfig)[source]¶
Update an authentication configuration in place
Note
Useful for updating previously stored authcfgs, when an authentication method has been significantly updated
- Parameters:
mconfig (QgsAuthMethodConfig)
- virtual updateNetworkProxy(self, proxy: QNetworkProxy, authcfg: str | None, dataprovider: str | None = '') bool [source]¶
Update proxy settings with authentication components
- Parameters:
proxy (QNetworkProxy)
authcfg (Optional[str]) – Authentication configuration ID
dataprovider (Optional[str] = '') – Textual key for a data provider, e.g. ‘proxy’, that allows for custom updater code specific to the provider
- Return type:
bool
- Returns:
Whether the update succeeded
- virtual updateNetworkReply(self, reply: QNetworkReply | None, authcfg: str | None, dataprovider: str | None = '') bool [source]¶
Update a network reply with authentication components
- Parameters:
reply (Optional[QNetworkReply]) – The network reply object to update
authcfg (Optional[str]) – Authentication configuration ID
dataprovider (Optional[str] = '') – Textual key for a data provider, e.g. ‘postgres’, that allows for custom updater code specific to the provider
- Return type:
bool
- Returns:
Whether the update succeeded
- virtual updateNetworkRequest(self, request: QNetworkRequest, authcfg: str | None, dataprovider: str | None = '') bool [source]¶
Update a network request with authentication components
- Parameters:
request (QNetworkRequest) – The network request to update
authcfg (Optional[str]) – Authentication configuration ID
dataprovider (Optional[str] = '') – Textual key for a data provider, e.g. ‘postgres’, that allows for custom updater code specific to the provider
- Return type:
bool
- Returns:
Whether the update succeeded