Skip to content

Commit

Permalink
Add settings key to disable automatic random password generation
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 9, 2023
1 parent 4eee81b commit eebb326
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions python/core/auto_generated/auth/qgsauthmanager.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and to utilize configurations through various authentication method plugins
%End
public:


enum MessageLevel
{
INFO,
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16800,7 +16800,8 @@ void QgisApp::masterPasswordSetup()
connect( QgsApplication::authManager(), &QgsAuthManager::authDatabaseEraseRequested,
this, &QgisApp::eraseAuthenticationDatabase );

if ( !QgsApplication::authManager()->masterPasswordHashInDatabase() && QgsApplication::authManager()->passwordHelperEnabled() )
if ( QgsAuthManager::settingsGenerateRandomPasswordForPasswordHelper->value()
&& !QgsApplication::authManager()->masterPasswordHashInDatabase() && QgsApplication::authManager()->passwordHelperEnabled() )
{
// if no master password set by user yet, just generate a new one and store it in the system keychain
QgsApplication::authManager()->createAndStoreRandomMasterPasswordInKeyChain();
Expand Down
4 changes: 3 additions & 1 deletion src/core/auth/qgsauthmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#include "qgsmessagelog.h"
#include "qgssettings.h"
#include "qgsruntimeprofiler.h"
#include "qgssettingsentryimpl.h"
#include "qgssettingstree.h"

QgsAuthManager *QgsAuthManager::sInstance = nullptr;

Expand All @@ -79,7 +81,7 @@ const QString QgsAuthManager::AUTH_CFG_REGEX = QStringLiteral( "authcfg=([a-z]|[
const QLatin1String QgsAuthManager::AUTH_PASSWORD_HELPER_KEY_NAME( "QGIS-Master-Password" );
const QLatin1String QgsAuthManager::AUTH_PASSWORD_HELPER_FOLDER_NAME( "QGIS" );


const QgsSettingsEntryBool *QgsAuthManager::settingsGenerateRandomPasswordForPasswordHelper = new QgsSettingsEntryBool( QStringLiteral( "generate-random-password-for-keychain" ), QgsSettingsTree::sTreeAuthentication, true, QStringLiteral( "Whether a random password should be automatically generated for the authentication database and stored in the system keychain." ) );

#if defined(Q_OS_MAC)
const QString QgsAuthManager::AUTH_PASSWORD_HELPER_DISPLAY_NAME( "Keychain" );
Expand Down
3 changes: 3 additions & 0 deletions src/core/auth/qgsauthmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class QgsAuthMethod;
class QgsAuthMethodEdit;
class QgsAuthProvider;
class QgsAuthMethodMetadata;
class QgsSettingsEntryBool;
class QTimer;


Expand All @@ -68,6 +69,8 @@ class CORE_EXPORT QgsAuthManager : public QObject

public:

static const QgsSettingsEntryBool *settingsGenerateRandomPasswordForPasswordHelper SIP_SKIP;

//! Message log level (mirrors that of QgsMessageLog, so it can also output there)
enum MessageLevel
{
Expand Down
1 change: 1 addition & 0 deletions src/core/settings/qgssettingstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class CORE_EXPORT QgsSettingsTree
static inline QgsSettingsTreeNode *sTreeWms = treeRoot()->createChildNode( QStringLiteral( "wms" ) );
static inline QgsSettingsTreeNode *sTreeMeasure = treeRoot()->createChildNode( QStringLiteral( "measure" ) );
static inline QgsSettingsTreeNode *sTreeAnnotations = treeRoot()->createChildNode( QStringLiteral( "annotations" ) );
static inline QgsSettingsTreeNode *sTreeAuthentication = treeRoot()->createChildNode( QStringLiteral( "authentication" ) );

#endif

Expand Down

0 comments on commit eebb326

Please sign in to comment.