QgsAuthSettingsWidget class

Widget for entering authentication credentials both in the form username/password and by using QGIS Authentication Database and its authentication configurations.

The widget also offers the functionality to convert username/password credentials to an authentication configuration.

Public types

enum WarningType { ProjectFile, UserSettings }
The WarningType enum is used to determine the text of the message shown to the user about the destination of the stored clear-text credentials from the "Basic" tab: depending on the provider or the settings, the credentials are stored in the user settings and/or in the project file.

Public static functions

static auto formattedWarning(WarningType warning) -> const QString
warning text message based upon where credentials are stored

Constructors, destructors, conversion operators

QgsAuthSettingsWidget(QWidget* parent = nullptr, const QString& configId = QString(), const QString& username = QString(), const QString& password = QString(), const QString& dataprovider = QString()) explicit
Create a dialog for setting an associated authentication config, either from existing configs, or creating/removing them from auth database.

Public functions

auto btnConvertToEncryptedIsEnabled() const -> bool
convertButtonEnabled, mainly useful for unit tests
auto configId() const -> const QString
configId
auto configurationTabIsSelected() -> bool
configurationTabIsSelected
auto dataprovider() const -> const QString
dataprovider
auto password() const -> const QString
password
void setBasicText(const QString& basicText)
setBasicText set the text of the warning label
void setConfigId(const QString& configId)
setConfigId set the authentication configuration id param configId the authentication configuration id
void setDataprovider(const QString& dataprovider)
setDataprovider set the data provider key for filtering compatible authentication configurations
void setPassword(const QString& password)
setPassword set the password
void setStorePasswordChecked(bool checked)
setStorePasswordCheched check the "Store" checkbox for the password
void setStoreUsernameChecked(bool checked)
setStoreUsernameChecked check the "Store" checkbox for the username
void setUsername(const QString& username)
setUsername set the username
void setWarningText(const QString& warningText)
setWarningText set the text of the warning label
void showStoreCheckboxes(bool enabled)
showStoreCheckboxes show the "Store" checkboxes for basic auth.
auto storePasswordIsChecked() const -> bool
storePassword
auto storeUsernameIsChecked() const -> bool
storeUsername
auto username() const -> const QString
username

Public slots

auto convertToEncrypted() -> bool
convertToEncrypted is called when the convert to encrypted button is clicked and it creates a Basic authentication configuration from username and password specified in the Basic tab
void passwordTextChanged(const QString& text)
Called when password text is changed.
void userNameTextChanged(const QString& text)
Called when user name text is changed.

Function documentation

static const QString QgsAuthSettingsWidget::formattedWarning(WarningType warning)

warning text message based upon where credentials are stored

Parameters
warning enum of warning type
Returns pre-formatted warning text

QgsAuthSettingsWidget::QgsAuthSettingsWidget(QWidget* parent = nullptr, const QString& configId = QString(), const QString& username = QString(), const QString& password = QString(), const QString& dataprovider = QString()) explicit

Create a dialog for setting an associated authentication config, either from existing configs, or creating/removing them from auth database.

Parameters
parent Parent widget
configId authentication configuration id
username
password
dataprovider The key of the calling layer provider, if applicable

bool QgsAuthSettingsWidget::btnConvertToEncryptedIsEnabled() const

convertButtonEnabled, mainly useful for unit tests

Returns true if the convert button is enabled

const QString QgsAuthSettingsWidget::configId() const

configId

Returns authentication configuration id

bool QgsAuthSettingsWidget::configurationTabIsSelected()

configurationTabIsSelected

Returns true if the configuration tab is the currently selected tab

const QString QgsAuthSettingsWidget::dataprovider() const

dataprovider

Returns the data provider key used to filter compatible authentication configurations

const QString QgsAuthSettingsWidget::password() const

password

Returns basic authentication password

void QgsAuthSettingsWidget::setBasicText(const QString& basicText)

setBasicText set the text of the warning label

Parameters
basicText the text of the basic tab label

void QgsAuthSettingsWidget::setDataprovider(const QString& dataprovider)

setDataprovider set the data provider key for filtering compatible authentication configurations

Parameters
dataprovider data provider key

void QgsAuthSettingsWidget::setPassword(const QString& password)

setPassword set the password

Parameters
password the password

void QgsAuthSettingsWidget::setStorePasswordChecked(bool checked)

setStorePasswordCheched check the "Store" checkbox for the password

Parameters
checked

void QgsAuthSettingsWidget::setStoreUsernameChecked(bool checked)

setStoreUsernameChecked check the "Store" checkbox for the username

Parameters
checked

void QgsAuthSettingsWidget::setUsername(const QString& username)

setUsername set the username

Parameters
username the user name

void QgsAuthSettingsWidget::setWarningText(const QString& warningText)

setWarningText set the text of the warning label

Parameters
warningText the text of the warning label

void QgsAuthSettingsWidget::showStoreCheckboxes(bool enabled)

showStoreCheckboxes show the "Store" checkboxes for basic auth.

Parameters
enabled

Some connection configurations allow the user to enter credentials for testing the connection without storing them in the project. "Store" checkboxes are disabled by default.

bool QgsAuthSettingsWidget::storePasswordIsChecked() const

storePassword

Returns true if "Store" checkbox for the password is checked

bool QgsAuthSettingsWidget::storeUsernameIsChecked() const

storeUsername

Returns true if "Store" checkbox for the username is checked

const QString QgsAuthSettingsWidget::username() const

username

Returns basic authentication username

bool QgsAuthSettingsWidget::convertToEncrypted() public slot

convertToEncrypted is called when the convert to encrypted button is clicked and it creates a Basic authentication configuration from username and password specified in the Basic tab

Returns return true on success

void QgsAuthSettingsWidget::passwordTextChanged(const QString& text) public slot

Called when password text is changed.

void QgsAuthSettingsWidget::userNameTextChanged(const QString& text) public slot

Called when user name text is changed.