1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Add PostgreSQL authentication backend (#9756)

* Add PostgreSQL authentication backend
This commit is contained in:
Loïc Blot 2020-04-27 06:54:48 +02:00 committed by GitHub
parent 2fe4641c1e
commit e564bf8ead
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 207 additions and 0 deletions

View file

@ -36,6 +36,7 @@ public:
void beginSave();
void endSave();
void rollback();
bool initialized() const;
@ -148,3 +149,26 @@ protected:
private:
bool playerDataExists(const std::string &playername);
};
class AuthDatabasePostgreSQL : private Database_PostgreSQL, public AuthDatabase
{
public:
AuthDatabasePostgreSQL(const std::string &connect_string);
virtual ~AuthDatabasePostgreSQL() = default;
virtual void pingDatabase() { Database_PostgreSQL::pingDatabase(); }
virtual bool getAuth(const std::string &name, AuthEntry &res);
virtual bool saveAuth(const AuthEntry &authEntry);
virtual bool createAuth(AuthEntry &authEntry);
virtual bool deleteAuth(const std::string &name);
virtual void listNames(std::vector<std::string> &res);
virtual void reload();
protected:
virtual void createDatabase();
virtual void initStatements();
private:
virtual void writePrivileges(const AuthEntry &authEntry);
};