17#include "ui_qgsauthmethodplugins.h"
33#include <QTableWidget>
36#include "moc_qgsautheditorwidgets.cpp"
38using namespace Qt::StringLiterals;
46 mAuthNotifyLayout =
new QVBoxLayout;
47 this->setLayout( mAuthNotifyLayout );
49 mAuthNotifyLayout->addWidget( mAuthNotify );
54 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
55 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [] {
QgsHelp::openHelp( u
"auth_system/auth_overview.html#authentication-methods"_s ); } );
62void QgsAuthMethodPlugins::setupTable()
64 tblAuthPlugins->setColumnCount( 3 );
65 tblAuthPlugins->verticalHeader()->hide();
66 tblAuthPlugins->horizontalHeader()->setVisible(
true );
67 tblAuthPlugins->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Method" ) ) );
68 tblAuthPlugins->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"Description" ) ) );
69 tblAuthPlugins->setHorizontalHeaderItem( 2,
new QTableWidgetItem( tr(
"Works with" ) ) );
70 tblAuthPlugins->horizontalHeader()->setStretchLastSection(
true );
71 tblAuthPlugins->setAlternatingRowColors(
true );
72 tblAuthPlugins->setColumnWidth( 0, 150 );
73 tblAuthPlugins->setColumnWidth( 1, 300 );
75 tblAuthPlugins->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
76 tblAuthPlugins->setSortingEnabled(
true );
77 tblAuthPlugins->setSelectionBehavior( QAbstractItemView::SelectRows );
80void QgsAuthMethodPlugins::populateTable()
85 const auto constAuthMethodKeys = authMethodKeys;
86 for (
const QString &authMethodKey : constAuthMethodKeys )
90 if ( !meta || !method )
92 QgsDebugError( u
"Load auth method instance FAILED for auth method key (%1)"_s.arg( authMethodKey ) );
96 QTableWidgetItem *twi =
new QTableWidgetItem( meta->
key() );
97 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
98 tblAuthPlugins->setItem( i, 0, twi );
101 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
102 tblAuthPlugins->setItem( i, 1, twi );
105 twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
106 tblAuthPlugins->setItem( i, 2, twi );
110 tblAuthPlugins->sortItems( 0 );
119 connect( btnCertManager, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnCertManager_clicked );
120 connect( btnAuthPlugins, &QPushButton::clicked,
this, &QgsAuthEditorWidgets::btnAuthPlugins_clicked );
123 wdgtConfigEditor->setRelayMessages(
false );
124 wdgtConfigEditor->setShowUtilitiesButton(
false );
125 setupUtilitiesMenu();
129 grpbxManagers->setEnabled(
false );
133void QgsAuthEditorWidgets::btnCertManager_clicked()
136 dlg->setWindowModality( Qt::ApplicationModal );
137 dlg->resize( 750, 500 );
142void QgsAuthEditorWidgets::btnAuthPlugins_clicked()
144 QgsAuthMethodPlugins *dlg =
new QgsAuthMethodPlugins(
this );
145 dlg->setWindowModality( Qt::WindowModal );
146 dlg->resize( 675, 500 );
151void QgsAuthEditorWidgets::setupUtilitiesMenu()
158 mActionImportAuthenticationConfigs =
new QAction( tr(
"Import Authentication Configurations from File…" ),
this );
159 mActionExportSelectedAuthenticationConfigs =
new QAction( tr(
"Export Selected Authentication Configurations to File…" ),
this );
160 mActionSetMasterPassword =
new QAction( tr(
"Input Master Password…" ),
this );
161 mActionClearCachedMasterPassword =
new QAction( tr(
"Clear Cached Master Password" ),
this );
162 mActionResetMasterPassword =
new QAction( tr(
"Reset Master Password…" ),
this );
163 mActionClearCachedAuthConfigs =
new QAction( tr(
"Clear Cached Authentication Configurations" ),
this );
164 mActionRemoveAuthConfigs =
new QAction( tr(
"Remove all Authentication Configurations…" ),
this );
165 mActionEraseAuthDatabase =
new QAction( tr(
"Erase Authentication Database…" ),
this );
167 mActionClearAccessCacheNow =
new QAction( tr(
"Clear Network Authentication Access Cache" ),
this );
168 mActionAutoClearAccessCache =
new QAction( tr(
"Automatically Clear Network Authentication Access Cache on SSL Errors" ),
this );
169 mActionAutoClearAccessCache->setCheckable(
true );
170 mActionAutoClearAccessCache->setChecked( QgsSettings().value( u
"clear_auth_cache_on_errors"_s,
true,
QgsSettings::Section::Auth ).toBool() );
174 mActionPasswordHelperLoggingEnable =
new QAction( tr(
"Enable Password Helper Debug Log" ),
this );
176 mActionPasswordHelperEnable->setCheckable(
true );
179 mActionPasswordHelperLoggingEnable->setCheckable(
true );
184 connect( mActionImportAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::importAuthenticationConfigs );
185 connect( mActionResetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::resetMasterPassword );
186 connect( mActionRemoveAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::removeAuthenticationConfigs );
187 connect( mActionEraseAuthDatabase, &QAction::triggered,
this, &QgsAuthEditorWidgets::eraseAuthenticationDatabase );
191 mActionImportAuthenticationConfigs->setEnabled(
false );
192 mActionResetMasterPassword->setEnabled(
false );
193 mActionRemoveAuthConfigs->setEnabled(
false );
194 mActionEraseAuthDatabase->setEnabled(
false );
197 connect( mActionExportSelectedAuthenticationConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs );
198 connect( mActionSetMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::setMasterPassword );
199 connect( mActionClearCachedMasterPassword, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedMasterPassword );
200 connect( mActionClearCachedAuthConfigs, &QAction::triggered,
this, &QgsAuthEditorWidgets::clearCachedAuthenticationConfigs );
202 connect( mActionPasswordHelperDelete, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperDelete );
203 connect( mActionPasswordHelperEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperEnableTriggered );
204 connect( mActionPasswordHelperLoggingEnable, &QAction::triggered,
this, &QgsAuthEditorWidgets::passwordHelperLoggingEnableTriggered );
206 connect( mActionClearAccessCacheNow, &QAction::triggered,
this, [
this] {
208 messageBar()->clearWidgets();
209 messageBar()->pushSuccess( tr(
"Auth cache cleared" ), tr(
"Network authentication cache has been cleared" ) );
211 connect( mActionAutoClearAccessCache, &QAction::triggered,
this, [](
bool checked ) { QgsSettings().setValue( u
"clear_auth_cache_on_errors"_s, checked,
QgsSettings::Section::Auth ); } );
213 mAuthUtilitiesMenu =
new QMenu(
this );
214 mAuthUtilitiesMenu->addAction( mActionSetMasterPassword );
215 mAuthUtilitiesMenu->addAction( mActionClearCachedMasterPassword );
216 mAuthUtilitiesMenu->addAction( mActionResetMasterPassword );
217 mAuthUtilitiesMenu->addSeparator();
218 mAuthUtilitiesMenu->addAction( mActionClearAccessCacheNow );
219 mAuthUtilitiesMenu->addAction( mActionAutoClearAccessCache );
220 mAuthUtilitiesMenu->addSeparator();
221 mAuthUtilitiesMenu->addAction( mActionPasswordHelperEnable );
222 mAuthUtilitiesMenu->addAction( mActionPasswordHelperDelete );
223 mAuthUtilitiesMenu->addAction( mActionPasswordHelperLoggingEnable );
224 mAuthUtilitiesMenu->addSeparator();
225 mAuthUtilitiesMenu->addAction( mActionClearCachedAuthConfigs );
226 mAuthUtilitiesMenu->addAction( mActionRemoveAuthConfigs );
227 mAuthUtilitiesMenu->addSeparator();
228 mAuthUtilitiesMenu->addAction( mActionImportAuthenticationConfigs );
229 mAuthUtilitiesMenu->addAction( mActionExportSelectedAuthenticationConfigs );
230 mAuthUtilitiesMenu->addSeparator();
231 mAuthUtilitiesMenu->addAction( mActionEraseAuthDatabase );
233 btnAuthUtilities->setMenu( mAuthUtilitiesMenu );
236void QgsAuthEditorWidgets::importAuthenticationConfigs()
241void QgsAuthEditorWidgets::exportSelectedAuthenticationConfigs()
243 if ( !wdgtConfigEditor )
249void QgsAuthEditorWidgets::setMasterPassword()
254void QgsAuthEditorWidgets::clearCachedMasterPassword()
259void QgsAuthEditorWidgets::resetMasterPassword()
264void QgsAuthEditorWidgets::clearCachedAuthenticationConfigs()
269void QgsAuthEditorWidgets::removeAuthenticationConfigs()
274void QgsAuthEditorWidgets::eraseAuthenticationDatabase()
279void QgsAuthEditorWidgets::authMessageLog(
const QString &message,
const QString &authtag,
Qgis::MessageLevel level )
281 messageBar()->clearWidgets();
282 messageBar()->pushMessage( authtag, message, level );
285void QgsAuthEditorWidgets::passwordHelperDelete()
290void QgsAuthEditorWidgets::passwordHelperEnableTriggered()
296void 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)