17#include "ui_qgsauthmethodplugins.h"
32#include <QTableWidget>
35#include "moc_qgsautheditorwidgets.cpp"
43 mAuthNotifyLayout =
new QVBoxLayout;
44 this->setLayout( mAuthNotifyLayout );
46 mAuthNotifyLayout->addWidget( mAuthNotify );
51 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
52 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [] {
53 QgsHelp::openHelp( QStringLiteral(
"auth_system/auth_overview.html#authentication-methods" ) );
61void QgsAuthMethodPlugins::setupTable()
63 tblAuthPlugins->setColumnCount( 3 );
64 tblAuthPlugins->verticalHeader()->hide();
65 tblAuthPlugins->horizontalHeader()->setVisible(
true );
66 tblAuthPlugins->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Method" ) ) );
67 tblAuthPlugins->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"Description" ) ) );
68 tblAuthPlugins->setHorizontalHeaderItem( 2,
new QTableWidgetItem( tr(
"Works with" ) ) );
69 tblAuthPlugins->horizontalHeader()->setStretchLastSection(
true );
70 tblAuthPlugins->setAlternatingRowColors(
true );
71 tblAuthPlugins->setColumnWidth( 0, 150 );
72 tblAuthPlugins->setColumnWidth( 1, 300 );
74 tblAuthPlugins->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
75 tblAuthPlugins->setSortingEnabled(
true );
76 tblAuthPlugins->setSelectionBehavior( QAbstractItemView::SelectRows );
79void QgsAuthMethodPlugins::populateTable()
84 const auto constAuthMethodKeys = authMethodKeys;
85 for (
const QString &authMethodKey : constAuthMethodKeys )
89 if ( !meta || !method )
91 QgsDebugError( QStringLiteral(
"Load auth method instance FAILED for auth method key (%1)" ).arg( authMethodKey ) );
95 QTableWidgetItem *twi =
new QTableWidgetItem( meta->
key() );
96 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
97 tblAuthPlugins->setItem( i, 0, twi );
100 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
101 tblAuthPlugins->setItem( i, 1, twi );
104 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
105 tblAuthPlugins->setItem( i, 2, twi );
109 tblAuthPlugins->sortItems( 0 );
118 connect( btnCertManager, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnCertManager_clicked );
119 connect( btnAuthPlugins, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnAuthPlugins_clicked );
122 wdgtConfigEditor->setRelayMessages(
false );
123 wdgtConfigEditor->setShowUtilitiesButton(
false );
124 setupUtilitiesMenu();
128 grpbxManagers->setEnabled(
false );
132void QgsAuthEditorWidgets::btnCertManager_clicked()
135 dlg->setWindowModality( Qt::ApplicationModal );
136 dlg->resize( 750, 500 );
141void QgsAuthEditorWidgets::btnAuthPlugins_clicked()
143 QgsAuthMethodPlugins *dlg =
new QgsAuthMethodPlugins(
this );
144 dlg->setWindowModality( Qt::WindowModal );
145 dlg->resize( 675, 500 );
150void QgsAuthEditorWidgets::setupUtilitiesMenu()
157 mActionImportAuthenticationConfigs =
new QAction( tr(
"Import Authentication Configurations from File…" ),
this );
158 mActionExportSelectedAuthenticationConfigs =
new QAction( tr(
"Export Selected Authentication Configurations to File…" ),
this );
159 mActionSetMasterPassword =
new QAction( tr(
"Input Master Password…" ),
this );
160 mActionClearCachedMasterPassword =
new QAction( tr(
"Clear Cached Master Password" ),
this );
161 mActionResetMasterPassword =
new QAction( tr(
"Reset Master Password…" ),
this );
162 mActionClearCachedAuthConfigs =
new QAction( tr(
"Clear Cached Authentication Configurations" ),
this );
163 mActionRemoveAuthConfigs =
new QAction( tr(
"Remove all Authentication Configurations…" ),
this );
164 mActionEraseAuthDatabase =
new QAction( tr(
"Erase Authentication Database…" ),
this );
166 mActionClearAccessCacheNow =
new QAction( tr(
"Clear Network Authentication Access Cache" ),
this );
167 mActionAutoClearAccessCache =
new QAction( tr(
"Automatically Clear Network Authentication Access Cache on SSL Errors" ),
this );
168 mActionAutoClearAccessCache->setCheckable(
true );
169 mActionAutoClearAccessCache->setChecked( QgsSettings().value( QStringLiteral(
"clear_auth_cache_on_errors" ),
true,
QgsSettings::Section::Auth ).toBool() );
173 mActionPasswordHelperLoggingEnable =
new QAction( tr(
"Enable Password Helper Debug Log" ),
this );
175 mActionPasswordHelperEnable->setCheckable(
true );
178 mActionPasswordHelperLoggingEnable->setCheckable(
true );
183 connect( mActionImportAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::importAuthenticationConfigs );
184 connect( mActionResetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::resetMasterPassword );
185 connect( mActionRemoveAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::removeAuthenticationConfigs );
186 connect( mActionEraseAuthDatabase, &QAction::triggered,
this, &QgsAuthEditorWidgets::eraseAuthenticationDatabase );
190 mActionImportAuthenticationConfigs->setEnabled(
false );
191 mActionResetMasterPassword->setEnabled(
false );
192 mActionRemoveAuthConfigs->setEnabled(
false );
193 mActionEraseAuthDatabase->setEnabled(
false );
196 connect( mActionExportSelectedAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs );
197 connect( mActionSetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::setMasterPassword );
198 connect( mActionClearCachedMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedMasterPassword );
199 connect( mActionClearCachedAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedAuthenticationConfigs );
201 connect( mActionPasswordHelperDelete, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperDelete );
202 connect( mActionPasswordHelperEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperEnableTriggered );
203 connect( mActionPasswordHelperLoggingEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered );
205 connect( mActionClearAccessCacheNow, &QAction::triggered,
this, [
this] {
207 messageBar()->clearWidgets();
208 messageBar()->pushSuccess( tr(
"Auth cache cleared" ), tr(
"Network authentication cache has been cleared" ) );
210 connect( mActionAutoClearAccessCache, &QAction::triggered,
this, [](
bool checked ) {
214 mAuthUtilitiesMenu =
new QMenu(
this );
215 mAuthUtilitiesMenu->addAction( mActionSetMasterPassword );
216 mAuthUtilitiesMenu->addAction( mActionClearCachedMasterPassword );
217 mAuthUtilitiesMenu->addAction( mActionResetMasterPassword );
218 mAuthUtilitiesMenu->addSeparator();
219 mAuthUtilitiesMenu->addAction( mActionClearAccessCacheNow );
220 mAuthUtilitiesMenu->addAction( mActionAutoClearAccessCache );
221 mAuthUtilitiesMenu->addSeparator();
222 mAuthUtilitiesMenu->addAction( mActionPasswordHelperEnable );
223 mAuthUtilitiesMenu->addAction( mActionPasswordHelperDelete );
224 mAuthUtilitiesMenu->addAction( mActionPasswordHelperLoggingEnable );
225 mAuthUtilitiesMenu->addSeparator();
226 mAuthUtilitiesMenu->addAction( mActionClearCachedAuthConfigs );
227 mAuthUtilitiesMenu->addAction( mActionRemoveAuthConfigs );
228 mAuthUtilitiesMenu->addSeparator();
229 mAuthUtilitiesMenu->addAction( mActionImportAuthenticationConfigs );
230 mAuthUtilitiesMenu->addAction( mActionExportSelectedAuthenticationConfigs );
231 mAuthUtilitiesMenu->addSeparator();
232 mAuthUtilitiesMenu->addAction( mActionEraseAuthDatabase );
234 btnAuthUtilities->setMenu( mAuthUtilitiesMenu );
237void QgsAuthEditorWidgets::importAuthenticationConfigs()
242void QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs()
244 if ( !wdgtConfigEditor )
250void QgsAuthEditorWidgets::setMasterPassword()
255void QgsAuthEditorWidgets::clearCachedMasterPassword()
260void QgsAuthEditorWidgets::resetMasterPassword()
265void QgsAuthEditorWidgets::clearCachedAuthenticationConfigs()
270void QgsAuthEditorWidgets::removeAuthenticationConfigs()
275void QgsAuthEditorWidgets::eraseAuthenticationDatabase()
280void QgsAuthEditorWidgets::authMessageLog(
const QString &message,
const QString &authtag,
Qgis::MessageLevel level )
282 messageBar()->clearWidgets();
283 messageBar()->pushMessage( authtag, message, level );
286void QgsAuthEditorWidgets::passwordHelperDelete()
291void QgsAuthEditorWidgets::passwordHelperEnableTriggered()
297void QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered()
MessageLevel
Level for messages This will be used both for message log and message bar in application.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
Dialog wrapper for widget to manage available certificate editors.
virtual bool isReadOnly() const
Returns true if the storage is read-only, false otherwise.
static void importAuthenticationConfigs(QgsMessageBar *msgbar)
Import authentication configurations from a XML file.
static void exportSelectedAuthenticationConfigs(QStringList authenticationConfigIds, QgsMessageBar *msgbar)
Exports selected authentication configurations to a XML file.
static void resetMasterPassword(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Reset the cached master password, updating its hash in authentication database and resetting all exis...
static void clearCachedMasterPassword(QgsMessageBar *msgbar)
Clear the currently cached master password (not its hash in database).
static void passwordHelperEnable(bool enabled, QgsMessageBar *msgbar)
Sets password helper enabled (enable/disable).
static void clearCachedAuthenticationConfigs(QgsMessageBar *msgbar)
Clear all cached authentication configs for session.
static void passwordHelperLoggingEnable(bool enabled, QgsMessageBar *msgbar, int timeout=0)
Sets password helper logging enabled (enable/disable).
static void eraseAuthenticationDatabase(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Completely clear out the authentication database (configs and master password).
static void removeAuthenticationConfigs(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Remove all authentication configs.
static void setMasterPassword(QgsMessageBar *msgbar)
Sets the cached master password (and verifies it if its hash is in authentication database).
static void passwordHelperDelete(QgsMessageBar *msgbar, QWidget *parent=nullptr)
Remove master password from wallet.
QgsAuthConfigurationStorageDb * defaultDbStorage() const
Transitional proxy to the first ready storage of database type.
void messageLog(const QString &message, const QString &tag=QgsAuthManager::AUTH_MAN_TAG, Qgis::MessageLevel level=Qgis::MessageLevel::Info) const
Custom logging signal to relay to console output and QgsMessageLog.
QgsAuthMethod * authMethod(const QString &authMethodKey)
Gets authentication method from the config/provider cache via its key.
QStringList authMethodsKeys(const QString &dataprovider=QString())
Gets keys of supported authentication methods.
const QgsAuthMethodMetadata * authMethodMetadata(const QString &authMethodKey)
Gets authentication method metadata via its key.
static QString passwordHelperDisplayName(bool titleCase=false)
Returns a translated display name of the password helper (platform dependent).
QgsAuthMethodPlugins(QWidget *parent=nullptr)
Construct a dialog for viewing available authentication method plugins.
QStringList supportedDataProviders() const
The data providers that the method supports, allowing for filtering out authcfgs that are not applica...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
A bar for displaying non-blocking messages to the user.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
#define QgsDebugError(str)