From: Ben Rosser Date: Fri, 9 Sep 2016 05:27:27 +0000 (-0400) Subject: Authenticator code cleanup as per review X-Git-Tag: travis-deploy-test~277 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=258d157a228d2b2b46b01d3b33ab932b9979436a Authenticator code cleanup as per review * Standardized on "authenticator" rather than "authBackend" * Removed XXXs and replaced with TODO or FIXME comments appropriately * Fixed a couple whitespace errors * Cleared up some comments in the ldap cmake * In the authenticator code, renamed displayName to backendId * Added missing newline at the end of authenticator.cpp --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bf56d71d..d527ee6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,8 @@ if (LINK_EXTRA) endif() -# LDAP Authentication (and other authentication backends). +# List of authenticators and the cmake flags to build them +# (currently that's just LDAP, but more can be added here). #################################################################### option(WITH_LDAP "Enable LDAP authentication support if present on system" ON) diff --git a/cmake/FindLdap.cmake b/cmake/FindLdap.cmake index 2f0c0dd2..55325478 100644 --- a/cmake/FindLdap.cmake +++ b/cmake/FindLdap.cmake @@ -13,16 +13,17 @@ if(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES) set(Ldap_FIND_QUIETLY TRUE) endif(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES) -#if(UNIX) # Attempt to link against ldap.h regardless of platform! FIND_PATH(LDAP_INCLUDE_DIR ldap.h) FIND_LIBRARY(LDAP_LIBRARIES NAMES ldap) FIND_LIBRARY(LBER_LIBRARIES NAMES lber) -#else(UNIX) +# It'd be nice to link against winldap on Windows, unfortunately +# the interfaces are different. In theory a compatibility shim +# could be written; if someone ever gets around to doing that these +# lines should be uncommented and used on Windows. # FIND_PATH(LDAP_INCLUDE_DIR winldap.h) # FIND_LIBRARY(LDAP_LIBRARIES NAMES wldap32) -#endif(UNIX) if(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES) set(LDAP_FOUND TRUE) diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index 7ded71d8..4a99890d 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -303,7 +303,7 @@ void ClientAuthHandler::handle(const ClientRegistered &msg) { _coreConfigured = msg.coreConfigured; _backendInfo = msg.backendInfo; - _authBackendInfo = msg.authBackendInfo; + _authenticatorInfo = msg.authenticatorInfo; Client::setCoreFeatures(static_cast(msg.coreFeatures)); @@ -322,7 +322,7 @@ void ClientAuthHandler::onConnectionReady() if (!_coreConfigured) { // start wizard - emit startCoreSetup(_backendInfo, _authBackendInfo); + emit startCoreSetup(_backendInfo, _authenticatorInfo); } else // TODO: check if we need LoginEnabled login(); diff --git a/src/client/clientauthhandler.h b/src/client/clientauthhandler.h index d6e54cd1..5ebd5305 100644 --- a/src/client/clientauthhandler.h +++ b/src/client/clientauthhandler.h @@ -70,7 +70,7 @@ signals: #endif void encrypted(bool isEncrypted = true); - void startCoreSetup(const QVariantList &backendInfo, const QVariantList &authBackendInfo); + void startCoreSetup(const QVariantList &backendInfo, const QVariantList &authenticatorInfo); void coreSetupSuccessful(); void coreSetupFailed(const QString &error); @@ -113,7 +113,7 @@ private: RemotePeer *_peer; bool _coreConfigured; QVariantList _backendInfo; - QVariantList _authBackendInfo; + QVariantList _authenticatorInfo; CoreAccount _account; bool _probing; bool _legacy; diff --git a/src/client/coreconnection.h b/src/client/coreconnection.h index f381c33f..4a1766e3 100644 --- a/src/client/coreconnection.h +++ b/src/client/coreconnection.h @@ -97,7 +97,7 @@ signals: void progressValueChanged(int value); void progressTextChanged(const QString &); - void startCoreSetup(const QVariantList &backendInfo, const QVariantList &authBackendInfo); + void startCoreSetup(const QVariantList &backendInfo, const QVariantList &authenticatorInfo); void coreSetupSuccess(); void coreSetupFailed(const QString &error); diff --git a/src/common/main.cpp b/src/common/main.cpp index 0441f2c4..71579df4 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -163,7 +163,7 @@ int main(int argc, char **argv) #endif cliParser->addOption("logfile", 'l', "Log to a file", "path"); cliParser->addOption("select-backend", 0, "Switch storage backend (migrating data if possible)", "backendidentifier"); - cliParser->addOption("select-authenticator", 0, "Switch auth backend", "authidentifier"); + cliParser->addOption("select-authenticator", 0, "Select authentication backend", "authidentifier"); cliParser->addSwitch("add-user", 0, "Starts an interactive session to add a new core user"); cliParser->addOption("change-userpass", 0, "Starts an interactive session to change the password of the user identified by ", "username"); cliParser->addSwitch("oidentd", 0, "Enable oidentd integration"); diff --git a/src/common/protocol.h b/src/common/protocol.h index d9d10490..f3c18e4c 100644 --- a/src/common/protocol.h +++ b/src/common/protocol.h @@ -81,20 +81,20 @@ struct ClientDenied : public HandshakeMessage struct ClientRegistered : public HandshakeMessage { - inline ClientRegistered(quint32 coreFeatures, bool coreConfigured, const QVariantList &backendInfo, bool sslSupported, const QVariantList &authBackendInfo) + inline ClientRegistered(quint32 coreFeatures, bool coreConfigured, const QVariantList &backendInfo, bool sslSupported, const QVariantList &authenticatorInfo) : coreFeatures(coreFeatures) , coreConfigured(coreConfigured) , backendInfo(backendInfo) - , authBackendInfo(authBackendInfo) + , authenticatorInfo(authenticatorInfo) , sslSupported(sslSupported) {} quint32 coreFeatures; bool coreConfigured; - // The authBackendInfo should be optional! + // The authenticatorInfo should be optional! QVariantList backendInfo; // TODO: abstract this better - QVariantList authBackendInfo; + QVariantList authenticatorInfo; // this is only used by the LegacyProtocol in compat mode bool sslSupported; diff --git a/src/common/protocols/datastream/datastreampeer.cpp b/src/common/protocols/datastream/datastreampeer.cpp index acf7a425..6a21a169 100644 --- a/src/common/protocols/datastream/datastreampeer.cpp +++ b/src/common/protocols/datastream/datastreampeer.cpp @@ -124,12 +124,12 @@ void DataStreamPeer::handleHandshakeMessage(const QVariantList &mapData) } else if (msgType == "ClientInitAck") { - handle(ClientRegistered(m["CoreFeatures"].toUInt(), m["Configured"].toBool(), m["StorageBackends"].toList(), false, m["AuthBackends"].toList())); // SupportsSsl obsolete + handle(ClientRegistered(m["CoreFeatures"].toUInt(), m["Configured"].toBool(), m["StorageBackends"].toList(), false, m["Authenticators"].toList())); // SupportsSsl obsolete } else if (msgType == "CoreSetupData") { QVariantMap map = m["SetupData"].toMap(); - handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap(), map["AuthBackend"].toString(), map["AuthProperties"].toMap())); + handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap(), map["Authenticator"].toString(), map["AuthProperties"].toMap())); } else if (msgType == "CoreSetupReject") { @@ -187,7 +187,7 @@ void DataStreamPeer::dispatch(const ClientRegistered &msg) { m["MsgType"] = "ClientInitAck"; m["CoreFeatures"] = msg.coreFeatures; m["StorageBackends"] = msg.backendInfo; - m["AuthBackends"] = msg.authBackendInfo; + m["Authenticators"] = msg.authenticatorInfo; m["LoginEnabled"] = m["Configured"] = msg.coreConfigured; writeMessage(m); @@ -203,8 +203,7 @@ void DataStreamPeer::dispatch(const SetupData &msg) map["ConnectionProperties"] = msg.setupData; // Auth backend properties. - // XXX: make these optional using core features. - map["AuthBackend"] = msg.authenticator; + map["Authenticator"] = msg.authenticator; map["AuthProperties"] = msg.authSetupData; QVariantMap m; diff --git a/src/common/protocols/legacy/legacypeer.cpp b/src/common/protocols/legacy/legacypeer.cpp index a0afebdb..f59dffa6 100644 --- a/src/common/protocols/legacy/legacypeer.cpp +++ b/src/common/protocols/legacy/legacypeer.cpp @@ -170,12 +170,12 @@ void LegacyPeer::handleHandshakeMessage(const QVariant &msg) socket()->setProperty("UseCompression", true); #endif - handle(ClientRegistered(m["CoreFeatures"].toUInt(), m["Configured"].toBool(), m["StorageBackends"].toList(), m["SupportSsl"].toBool(), m["AuthBackends"].toList())); + handle(ClientRegistered(m["CoreFeatures"].toUInt(), m["Configured"].toBool(), m["StorageBackends"].toList(), m["SupportSsl"].toBool(), m["Authenticators"].toList())); } else if (msgType == "CoreSetupData") { QVariantMap map = m["SetupData"].toMap(); - handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap(), map["AuthBackend"].toString(), map["AuthProperties"].toMap())); + handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap(), map["Authenticator"].toString(), map["AuthProperties"].toMap())); } else if (msgType == "CoreSetupReject") { @@ -242,7 +242,7 @@ void LegacyPeer::dispatch(const ClientRegistered &msg) { m["MsgType"] = "ClientInitAck"; m["CoreFeatures"] = msg.coreFeatures; m["StorageBackends"] = msg.backendInfo; - m["AuthBackends"] = msg.authBackendInfo; + m["Authenticators"] = msg.authenticatorInfo; // FIXME only in compat mode m["ProtocolVersion"] = protocolVersion; @@ -265,10 +265,9 @@ void LegacyPeer::dispatch(const SetupData &msg) map["AdminPasswd"] = msg.adminPassword; map["Backend"] = msg.backend; map["ConnectionProperties"] = msg.setupData; - + // Auth backend properties. - // XXX: make these optional using core features. - map["AuthBackend"] = msg.authenticator; + map["Authenticator"] = msg.authenticator; map["AuthProperties"] = msg.authSetupData; QVariantMap m; diff --git a/src/common/quassel.h b/src/common/quassel.h index c661320d..eb85ebf6 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -77,7 +77,7 @@ public: DccFileTransfer = 0x0100, AwayFormatTimestamp = 0x0200, /// Timestamp formatting in away (e.g. %%hh:mm%%) // Whether or not the core supports auth backends. - AuthBackends = 0x0400, + Authenticators = 0x0400, NumFeatures = 0x0400 }; diff --git a/src/core/authenticator.cpp b/src/core/authenticator.cpp index 018c0cdf..fa52b62b 100644 --- a/src/core/authenticator.cpp +++ b/src/core/authenticator.cpp @@ -23,4 +23,5 @@ Authenticator::Authenticator(QObject *parent) : QObject(parent) { -} \ No newline at end of file +} + diff --git a/src/core/authenticator.h b/src/core/authenticator.h index 30f469e1..ce8a42af 100644 --- a/src/core/authenticator.h +++ b/src/core/authenticator.h @@ -52,7 +52,7 @@ public slots: //! Returns the display name of the authenticator backend /** \return A string that can be used by the client to name the authenticator backend */ - virtual QString displayName() const = 0; + virtual QString backendId() const = 0; //! Returns a description of this authenticator backend /** \return A string that can be displayed by the client to describe the authenticator */ diff --git a/src/core/core.cpp b/src/core/core.cpp index 67f3a815..6ad67026 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -175,7 +175,7 @@ Core::Core() } registerStorageBackends(); - registerAuthenticatorBackends(); + registerAuthenticators(); connect(&_storageSyncTimer, SIGNAL(timeout()), this, SLOT(syncStorage())); _storageSyncTimer.start(10 * 60 * 1000); // 10 minutes @@ -191,7 +191,7 @@ void Core::init() // Not entirely sure what is 'legacy' about the above, but it seems to be the way things work! QVariantMap authSettings = cs.authSettings().toMap(); - initAuthenticator(authSettings.value("AuthBackend").toString(), authSettings.value("ConnectionProperties").toMap()); + initAuthenticator(authSettings.value("Authenticator").toString(), authSettings.value("ConnectionProperties").toMap()); if (Quassel::isOptionSet("select-backend") || Quassel::isOptionSet("select-authenticator")) { if (Quassel::isOptionSet("select-backend")) { @@ -248,7 +248,7 @@ Core::~Core() } qDeleteAll(_sessions); qDeleteAll(_storageBackends); - qDeleteAll(_authenticatorBackends); + qDeleteAll(_authenticators); } @@ -299,13 +299,13 @@ void Core::restoreState() /*** Core Setup ***/ -QString Core::setup(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authBackend, const QVariantMap &authSetupData) +QString Core::setup(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupData) { - return instance()->setupCore(adminUser, adminPassword, backend, setupData, authBackend, authSetupData); + return instance()->setupCore(adminUser, adminPassword, backend, setupData, authenticator, authSetupData); } -QString Core::setupCore(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authBackend, const QVariantMap &authSetupData) +QString Core::setupCore(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupData) { if (_configured) return tr("Core is already configured! Not configuring again..."); @@ -317,8 +317,8 @@ QString Core::setupCore(const QString &adminUser, const QString &adminPassword, return tr("Could not setup storage!"); } - quInfo() << "Selected authenticator: " << authBackend; - if (!(_configured = initAuthenticator(authBackend, authSetupData, true))) + quInfo() << "Selected authenticator: " << authenticator; + if (!(_configured = initAuthenticator(authenticator, authSetupData, true))) { return tr("Could not setup authenticator!"); } @@ -326,7 +326,7 @@ QString Core::setupCore(const QString &adminUser, const QString &adminPassword, if (!saveBackendSettings(backend, setupData)) { return tr("Could not save backend settings, probably a permission problem."); } - saveAuthBackendSettings(authBackend, authSetupData); + saveAuthenticatorSettings(authenticator, authSetupData); quInfo() << qPrintable(tr("Creating admin user...")); _storage->addUser(adminUser, adminPassword); @@ -390,21 +390,21 @@ void Core::unregisterStorageBackend(Storage *backend) // Authentication handling, now independent from storage. // Register and unregister authenticators. -void Core::registerAuthenticatorBackends() +void Core::registerAuthenticators() { // Register new authentication backends here! - registerAuthenticatorBackend(new SqlAuthenticator(this)); + registerAuthenticator(new SqlAuthenticator(this)); #ifdef HAVE_LDAP - registerAuthenticatorBackend(new LdapAuthenticator(this)); + registerAuthenticator(new LdapAuthenticator(this)); #endif } -bool Core::registerAuthenticatorBackend(Authenticator *authenticator) +bool Core::registerAuthenticator(Authenticator *authenticator) { if (authenticator->isAvailable()) { - _authenticatorBackends[authenticator->displayName()] = authenticator; + _authenticators[authenticator->backendId()] = authenticator; return true; } else { authenticator->deleteLater(); @@ -412,18 +412,18 @@ bool Core::registerAuthenticatorBackend(Authenticator *authenticator) } } -void Core::unregisterAuthenticatorBackends() +void Core::unregisterAuthenticators() { - foreach(Authenticator* a, _authenticatorBackends.values()) + foreach(Authenticator* a, _authenticators.values()) { a->deleteLater(); } - _authenticatorBackends.clear(); + _authenticators.clear(); } -void Core::unregisterAuthenticatorBackend(Authenticator *backend) +void Core::unregisterAuthenticator(Authenticator *backend) { - _authenticatorBackends.remove(backend->displayName()); + _authenticators.remove(backend->backendId()); backend->deleteLater(); } @@ -467,18 +467,19 @@ bool Core::initStorage(const QString &backend, const QVariantMap &settings, bool return true; } -// XXX: TODO: Apparently, this is legacy? +// FIXME: Apparently, this is the legacy way of initting storage backends? +// If there's a not-legacy way, it should be used here bool Core::initAuthenticator(const QString &backend, const QVariantMap &settings, bool setup) { _authenticator = 0; if (backend.isEmpty()) { - return false; + return false; } Authenticator *authenticator = 0; - if (_authenticatorBackends.contains(backend)) { - authenticator = _authenticatorBackends[backend]; + if (_authenticators.contains(backend)) { + authenticator = _authenticators[backend]; } else { qCritical() << "Selected auth backend is not available:" << backend; @@ -498,8 +499,8 @@ bool Core::initAuthenticator(const QString &backend, const QVariantMap &settings exit(EXIT_FAILURE); case Authenticator::IsReady: // delete all other backends - _authenticatorBackends.remove(backend); - unregisterAuthenticatorBackends(); + _authenticators.remove(backend); + unregisterAuthenticators(); } _authenticator = authenticator; return true; @@ -792,9 +793,9 @@ QVariantList Core::backendInfo() QVariantList Core::authenticatorInfo() { QVariantList backends; - foreach(const Authenticator *backend, instance()->_authenticatorBackends.values()) { + foreach(const Authenticator *backend, instance()->_authenticators.values()) { QVariantMap v; - v["DisplayName"] = backend->displayName(); + v["DisplayName"] = backend->backendId(); v["Description"] = backend->description(); v["SetupKeys"] = backend->setupKeys(); v["SetupDefaults"] = backend->setupDefaults(); @@ -885,25 +886,25 @@ bool Core::selectBackend(const QString &backend) return true; } -// XXX: I am not sure if this function is implemented correctly. +// TODO: I am not sure if this function is implemented correctly. // There is currently no concept of migraiton between auth backends. bool Core::selectAuthenticator(const QString &backend) { // Register all authentication backends. - registerAuthenticatorBackends(); - if (!_authenticatorBackends.contains(backend)) { + registerAuthenticators(); + if (!_authenticators.contains(backend)) { qWarning() << qPrintable(QString("Core::selectAuthenticator(): unsupported backend: %1").arg(backend)); - qWarning() << " supported backends are:" << qPrintable(QStringList(_authenticatorBackends.keys()).join(", ")); + qWarning() << " supported backends are:" << qPrintable(QStringList(_authenticators.keys()).join(", ")); return false; } - Authenticator *authenticator = _authenticatorBackends[backend]; + Authenticator *authenticator = _authenticators[backend]; QVariantMap settings = promptForSettings(authenticator); Authenticator::State state = authenticator->init(settings); switch (state) { case Authenticator::IsReady: - saveAuthBackendSettings(backend, settings); + saveAuthenticatorSettings(backend, settings); qWarning() << "Switched auth backend to:" << qPrintable(backend); // qWarning() << "Auth backend already initialized. Skipping Migration"; return true; @@ -921,7 +922,7 @@ bool Core::selectAuthenticator(const QString &backend) return false; } - saveAuthBackendSettings(backend, settings); + saveAuthenticatorSettings(backend, settings); qWarning() << "Switched auth backend to:" << qPrintable(backend); } @@ -1030,7 +1031,7 @@ bool Core::changeUserPassword(UserId userId, const QString &password) return instance()->_storage->updateUser(userId, password); } -// XXX: this code isn't currently 100% optimal because the core +// TODO: this code isn't currently 100% optimal because the core // doesn't know it can have multiple auth providers configured (there aren't // multiple auth providers at the moment anyway) and we have hardcoded the // Database provider to be always allowed. @@ -1039,7 +1040,7 @@ bool Core::canChangeUserPassword(UserId userId) QString authProvider = instance()->_storage->getUserAuthenticator(userId); if (authProvider != "Database") { - if (authProvider != instance()->_authenticator->displayName()) { + if (authProvider != instance()->_authenticator->backendId()) { return false; } else if (instance()->_authenticator->canChangePassword()) { return false; @@ -1088,10 +1089,10 @@ bool Core::saveBackendSettings(const QString &backend, const QVariantMap &settin return s.sync(); } -void Core::saveAuthBackendSettings(const QString &backend, const QVariantMap &settings) +void Core::saveAuthenticatorSettings(const QString &backend, const QVariantMap &settings) { QVariantMap dbsettings; - dbsettings["AuthBackend"] = backend; + dbsettings["Authenticator"] = backend; dbsettings["ConnectionProperties"] = settings; CoreSettings().setAuthSettings(dbsettings); } diff --git a/src/core/core.h b/src/core/core.h index 3eb43132..66fc50b0 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -556,7 +556,7 @@ public: return (backend->displayName() == "SQLite") ? true : false; } - static QString setup(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authBackend, const QVariantMap &authSetupMap); + static QString setup(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupMap); static inline QTimer &syncTimer() { return instance()->_storageSyncTimer; } @@ -570,7 +570,7 @@ public slots: */ void syncStorage(); void setupInternalClientSession(InternalPeer *clientConnection); - QString setupCore(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authBackend, const QVariantMap &authSetupMap); + QString setupCore(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupMap); signals: //! Sent when a BufferInfo is updated in storage. @@ -612,16 +612,17 @@ private: void unregisterStorageBackends(); void unregisterStorageBackend(Storage *); - void registerAuthenticatorBackends(); - bool registerAuthenticatorBackend(Authenticator *); - void unregisterAuthenticatorBackends(); - void unregisterAuthenticatorBackend(Authenticator *); + void registerAuthenticators(); + bool registerAuthenticator(Authenticator *); + void unregisterAuthenticators(); + void unregisterAuthenticator(Authenticator *); bool selectBackend(const QString &backend); bool selectAuthenticator(const QString &backend); bool createUser(); + bool saveBackendSettings(const QString &backend, const QVariantMap &settings); - void saveAuthBackendSettings(const QString &backend, const QVariantMap &settings); + void saveAuthenticatorSettings(const QString &backend, const QVariantMap &settings); QVariantMap promptForSettings(const Storage *storage); QVariantMap promptForSettings(const Authenticator *authenticator); @@ -645,7 +646,7 @@ private: OidentdConfigGenerator *_oidentdConfigGenerator; QHash _storageBackends; - QHash _authenticatorBackends; + QHash _authenticators; QDateTime _startTime; diff --git a/src/core/coreauthhandler.cpp b/src/core/coreauthhandler.cpp index a4c06f33..c7251cfd 100644 --- a/src/core/coreauthhandler.cpp +++ b/src/core/coreauthhandler.cpp @@ -196,16 +196,16 @@ void CoreAuthHandler::handle(const SetupData &msg) if (!checkClientRegistered()) return; - // The default parameter to authBackend is Database. + // The default parameter to authenticator is Database. // Maybe this should be hardcoded elsewhere, i.e. as a define. - QString authBackend = msg.authenticator; - quInfo() << "[" << authBackend << "]"; - if (authBackend.trimmed().isEmpty() || authBackend == 0) + QString authenticator = msg.authenticator; + quInfo() << "[" << authenticator << "]"; + if (authenticator.trimmed().isEmpty() || authenticator == 0) { - authBackend = QString("Database"); + authenticator = QString("Database"); } - QString result = Core::setup(msg.adminUser, msg.adminPassword, msg.backend, msg.setupData, authBackend, msg.authSetupData); + QString result = Core::setup(msg.adminUser, msg.adminPassword, msg.backend, msg.setupData, authenticator, msg.authSetupData); if (!result.isEmpty()) _peer->dispatch(SetupFailed(result)); else diff --git a/src/core/ldapauthenticator.cpp b/src/core/ldapauthenticator.cpp index 5b62b89b..240e0ea3 100644 --- a/src/core/ldapauthenticator.cpp +++ b/src/core/ldapauthenticator.cpp @@ -59,11 +59,11 @@ LdapAuthenticator::~LdapAuthenticator() bool LdapAuthenticator::isAvailable() const { - // XXX: probably this should test if we can speak to the LDAP server. + // FIXME: probably this should test if we can speak to the LDAP server. return true; } -QString LdapAuthenticator::displayName() const +QString LdapAuthenticator::backendId() const { // We identify the backend to use for the monolithic core by its displayname. // so only change this string if you _really_ have to and make sure the core @@ -110,7 +110,7 @@ void LdapAuthenticator::setConnectionProperties(const QVariantMap &properties) _uidAttribute = properties["UID Attribute"].toString(); } -// XXX: this code is sufficiently general that in the future, perhaps an abstract +// TODO: this code is sufficiently general that in the future, perhaps an abstract // class should be created implementing it. // i.e. a provider that does its own thing and then pokes at the current storage // through the default core method. @@ -130,9 +130,9 @@ UserId LdapAuthenticator::validateUser(const QString &username, const QString &p UserId quasselID = Core::validateUser(username, QString()); if (!quasselID.isValid()) { - return Core::addUser(username, QString(), displayName()); + return Core::addUser(username, QString(), backendId()); } - else if (!(Core::checkAuthProvider(quasselID, displayName()))) + else if (!(Core::checkAuthProvider(quasselID, backendId()))) { return 0; } @@ -153,11 +153,11 @@ Authenticator::State LdapAuthenticator::init(const QVariantMap &settings) bool status = ldapConnect(); if (!status) { - quInfo() << qPrintable(displayName()) << "Authenticator cannot connect."; + quInfo() << qPrintable(backendId()) << "Authenticator cannot connect."; return NotAvailable; } - quInfo() << qPrintable(displayName()) << "Authenticator is ready."; + quInfo() << qPrintable(backendId()) << "Authenticator is ready."; return IsReady; } diff --git a/src/core/ldapauthenticator.h b/src/core/ldapauthenticator.h index 2281c687..ff05c4f3 100644 --- a/src/core/ldapauthenticator.h +++ b/src/core/ldapauthenticator.h @@ -57,7 +57,7 @@ public: public slots: /* General */ bool isAvailable() const; - QString displayName() const; + QString backendId() const; QString description() const; virtual QStringList setupKeys() const; virtual QVariantMap setupDefaults() const; diff --git a/src/core/sqlauthenticator.cpp b/src/core/sqlauthenticator.cpp index 52f0ac64..f1ed1697 100644 --- a/src/core/sqlauthenticator.cpp +++ b/src/core/sqlauthenticator.cpp @@ -38,11 +38,11 @@ SqlAuthenticator::~SqlAuthenticator() bool SqlAuthenticator::isAvailable() const { - // XXX: probably this should query the current storage (see the ::init routine too). + // FIXME: probably this should query the current storage (see the ::init routine too). return true; } -QString SqlAuthenticator::displayName() const +QString SqlAuthenticator::backendId() const { // We identify the backend to use for the monolithic core by its displayname. // so only change this string if you _really_ have to and make sure the core @@ -71,6 +71,6 @@ Authenticator::State SqlAuthenticator::init(const QVariantMap &settings) // TODO: FIXME: this should check if the storage provider is ready, but I don't // know if there's an exposed way to do that at the moment. - quInfo() << qPrintable(displayName()) << "Authenticator is ready."; + quInfo() << qPrintable(backendId()) << "Authenticator is ready."; return IsReady; } diff --git a/src/core/sqlauthenticator.h b/src/core/sqlauthenticator.h index 378a9d4b..4f2c71f1 100644 --- a/src/core/sqlauthenticator.h +++ b/src/core/sqlauthenticator.h @@ -34,7 +34,7 @@ public: public slots: /* General */ bool isAvailable() const; - QString displayName() const; + QString backendId() const; QString description() const; virtual inline QStringList setupKeys() const { return QStringList(); } virtual inline QVariantMap setupDefaults() const { return QVariantMap(); } diff --git a/src/qtui/coreconfigwizard.cpp b/src/qtui/coreconfigwizard.cpp index 5119f17d..ee9dd0dc 100644 --- a/src/qtui/coreconfigwizard.cpp +++ b/src/qtui/coreconfigwizard.cpp @@ -94,7 +94,7 @@ QHash CoreConfigWizard::authenticators() const return _authenticators; } -void CoreConfigWizard::prepareCoreSetup(const QString &backend, const QVariantMap &properties, const QString &authBackend, const QVariantMap &authProperties) +void CoreConfigWizard::prepareCoreSetup(const QString &backend, const QVariantMap &properties, const QString &authenticator, const QVariantMap &authProperties) { // Prevent the user from changing any settings he already specified... foreach(int idx, visitedPages()) @@ -102,11 +102,11 @@ void CoreConfigWizard::prepareCoreSetup(const QString &backend, const QVariantMa // FIXME? We need to be able to set up older cores that don't have auth backend support. // So if the core doesn't support that feature, don't pass those parameters. - if (!(Client::coreFeatures() & Quassel::AuthBackends)) + if (!(Client::coreFeatures() & Quassel::Authenticators)) { coreConnection()->setupCore(Protocol::SetupData(field("adminUser.user").toString(), field("adminUser.password").toString(), backend, properties)); } else { - coreConnection()->setupCore(Protocol::SetupData(field("adminUser.user").toString(), field("adminUser.password").toString(), backend, properties, authBackend, authProperties)); + coreConnection()->setupCore(Protocol::SetupData(field("adminUser.user").toString(), field("adminUser.password").toString(), backend, properties, authenticator, authProperties)); } } @@ -194,7 +194,7 @@ AdminUserPage::AdminUserPage(QWidget *parent) : QWizardPage(parent) int AdminUserPage::nextId() const { // If the core doesn't support auth backends, skip that page! - if (!(Client::coreFeatures() & Quassel::AuthBackends)) + if (!(Client::coreFeatures() & Quassel::Authenticators)) { return CoreConfigWizard::StorageSelectionPage; } else { @@ -534,14 +534,14 @@ void SyncPage::initializePage() // Fill in sync info about the authentication layer. AuthenticationSelectionPage *authPage = qobject_cast(wizard()->page(CoreConfigWizard::AuthenticationSelectionPage)); - QString authBackend = authPage->selectedBackend(); + QString authenticator = authPage->selectedBackend(); QVariantMap authProperties = authPage->connectionProperties(); - Q_ASSERT(!authBackend.isEmpty()); - ui.authBackend->setText(authBackend); + Q_ASSERT(!authenticator.isEmpty()); + ui.authenticator->setText(authenticator); ui.user->setText(wizard()->field("adminUser.user").toString()); - emit setupCore(backend, properties, authBackend, authProperties); + emit setupCore(backend, properties, authenticator, authProperties); } diff --git a/src/qtui/coreconfigwizard.h b/src/qtui/coreconfigwizard.h index 5b7cb8af..b22fd19c 100644 --- a/src/qtui/coreconfigwizard.h +++ b/src/qtui/coreconfigwizard.h @@ -69,7 +69,7 @@ public slots: void syncFinished(); private slots: - void prepareCoreSetup(const QString &backend, const QVariantMap &properties, const QString &authBackend, const QVariantMap &authProperties); + void prepareCoreSetup(const QString &backend, const QVariantMap &properties, const QString &authenticator, const QVariantMap &authProperties); void coreSetupSuccess(); void coreSetupFailed(const QString &); void startOver(); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index f6aa446c..4495bfeb 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1366,9 +1366,9 @@ void MainWin::showCoreConnectionDlg() } -void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantList &authBackends) +void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantList &authenticators) { - CoreConfigWizard *wizard = new CoreConfigWizard(Client::coreConnection(), backends, authBackends, this); + CoreConfigWizard *wizard = new CoreConfigWizard(Client::coreConnection(), backends, authenticators, this); wizard->show(); } diff --git a/src/qtui/ui/coreconfigwizardsyncpage.ui b/src/qtui/ui/coreconfigwizardsyncpage.ui index 1911be9e..6345ef74 100644 --- a/src/qtui/ui/coreconfigwizardsyncpage.ui +++ b/src/qtui/ui/coreconfigwizardsyncpage.ui @@ -77,7 +77,7 @@ - + bar