X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fcore.h;h=66fc50b01759a06e67fc9bec8f59388ada5be79c;hb=4b0caf61565c8791efba283bbcaf73530b9feafc;hp=ff226a8fdd5434e4959bc295c84f3b0409552153;hpb=931e5280abc6738f94ac052af2a7e31e82487cf1;p=quassel.git diff --git a/src/core/core.h b/src/core/core.h index ff226a8f..66fc50b0 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -84,15 +84,26 @@ public: static inline UserId authenticateUser(const QString &userName, const QString &password) { return instance()->_authenticator->validateUser(userName, password); } - + //! Add a new user, exposed so auth providers can call this without being the storage. /** * \param userName The user's login name * \param password The user's uncrypted password + * \param authenticator The name of the auth provider service used to log the user in, defaults to "Database". * \return The user's ID if valid; 0 otherwise */ - static inline UserId addUser(const QString &userName, const QString &password) { - return instance()->_storage->addUser(userName, password); + static inline UserId addUser(const QString &userName, const QString &password, const QString &authenticator = "Database") { + return instance()->_storage->addUser(userName, password, authenticator); + } + + //! Does a comparison test against the authenticator in the database and the authenticator currently in use for a UserID. + /** + * \param userid The user's ID (note: not login name). + * \param authenticator The name of the auth provider service used to log the user in, defaults to "Database". + * \return True if the userid was configured with the passed authenticator, false otherwise. + */ + static inline bool checkAuthProvider(const UserId userid, const QString &authenticator) { + return instance()->_storage->getUserAuthenticator(userid) == authenticator; } //! Change a user's password @@ -103,6 +114,13 @@ public: */ static bool changeUserPassword(UserId userId, const QString &password); + //! Check if we can change a user password. + /** + * \param userID The user's ID + * \return true, if we can change their password, false otherwise + */ + static bool canChangeUserPassword(UserId userId); + //! Store a user setting persistently /** * \param userId The users Id @@ -538,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; } @@ -552,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. @@ -572,7 +590,7 @@ private slots: bool initStorage(const QString &backend, const QVariantMap &settings, bool setup = false); bool initAuthenticator(const QString &backend, const QVariantMap &settings, bool setup = false); - + void socketError(QAbstractSocket::SocketError err, const QString &errorString); void setupClientSession(RemotePeer *, UserId); @@ -593,17 +611,22 @@ private: bool registerStorageBackend(Storage *); 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); + QVariantMap promptForSettings(QStringList keys, QVariantMap defaults); private: QSet _connectingClients; @@ -623,7 +646,7 @@ private: OidentdConfigGenerator *_oidentdConfigGenerator; QHash _storageBackends; - QHash _authenticatorBackends; + QHash _authenticators; QDateTime _startTime;