PgServerObject now contains a list of acl's for the object so all the different objects
can use this implementation.
This commit is contained in:
parent
efb3e71556
commit
93c8b49f61
6 changed files with 284 additions and 36 deletions
|
|
@ -3,13 +3,83 @@
|
|||
|
||||
#include <QString>
|
||||
#include "PgObject.h"
|
||||
#include "Pgsql_Value.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
enum class Privilege {
|
||||
Select,
|
||||
Update,
|
||||
Insert,
|
||||
Delete,
|
||||
Truncate,
|
||||
References,
|
||||
Trigger,
|
||||
Execute,
|
||||
Usage,
|
||||
Create,
|
||||
Connect,
|
||||
Temporary
|
||||
};
|
||||
|
||||
char privilegeToChar(Privilege p);
|
||||
|
||||
enum class PrivValue {
|
||||
No, Yes, YesWithGrant
|
||||
};
|
||||
|
||||
class PgAcl {
|
||||
public:
|
||||
PgAcl() = default;
|
||||
explicit PgAcl(const QString &acl);
|
||||
void setFromString(const QString &acl);
|
||||
|
||||
PrivValue privilege(Privilege priv) const;
|
||||
PrivValue privilege(char c) const;
|
||||
const QString& grantee() const { return m_grantee; }
|
||||
const QString& grantor() const { return m_grantor; }
|
||||
QString singleString() const;
|
||||
private:
|
||||
QString m_grantee;
|
||||
QString m_grantor;
|
||||
QString m_privileges;
|
||||
};
|
||||
|
||||
using AclList = std::vector<PgAcl>;
|
||||
|
||||
void operator<<(PgAcl &acl, const Pgsql::Value &v);
|
||||
|
||||
namespace Pgsql {
|
||||
template <>
|
||||
PgAcl StringToArrayElem<PgAcl>(std::string_view sv);
|
||||
}
|
||||
|
||||
/// Base object for objects that belong to a server
|
||||
class PgServerObject: public PgObject {
|
||||
public:
|
||||
using PgObject::PgObject;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief setAcls Takes the acl array as stored by postgres as a single string
|
||||
* and decodes it directly into an AclList.
|
||||
* @param acls
|
||||
*
|
||||
*/
|
||||
void setAcls(AclList acls);
|
||||
QString aclString() const;
|
||||
/**
|
||||
* @brief grantSql
|
||||
* @param all_pattern Used to recognize when a GRANT ALL can be generated but also to not consider irrelevant letters.
|
||||
* @param grantee
|
||||
* @param column
|
||||
* @return
|
||||
*/
|
||||
QString grantSql(const QString &all_pattern, const QString &grantee, const QString &column) const;
|
||||
|
||||
private:
|
||||
AclList m_acls;
|
||||
};
|
||||
|
||||
#endif // PGSERVEROBJECT_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue