19 #include "repo_bson.h"
24 enum class DBActions {
25 INSERT, UPDATE, REMOVE, FIND, CREATE_USER, CREATE_ROLE,
26 DROP_ROLE, GRANT_ROLE, REVOKE_ROLE, VIEW_ROLE, UNKNOWN
28 enum class AccessRight { READ, WRITE, READ_WRITE };
33 std::string collection;
34 std::vector<DBActions> actions;
42 AccessRight permission;
47 #define REPO_ROLE_LABEL_ROLE "role"
48 #define REPO_ROLE_LABEL_DATABASE "db"
49 #define REPO_ROLE_LABEL_COLLECTION "collection"
50 #define REPO_ROLE_LABEL_RESOURCE "resource"
51 #define REPO_ROLE_LABEL_ACTIONS "actions"
52 #define REPO_ROLE_LABEL_PRIVILEGES "privileges"
53 #define REPO_ROLE_LABEL_INHERITED_ROLES "roles"
70 static std::string dbActionToString(
const DBActions &action);
77 static std::vector<std::string> dbActionsToStrings(
78 const std::vector<DBActions> &actions);
85 static DBActions stringToDBAction(
const std::string &action);
93 static std::vector<DBActions> stringsToDBActions(
94 const std::vector<std::string> &strings);
101 static std::vector<RepoPrivilege> translatePermissions(
102 const std::vector<RepoPermission> &permissions);
109 static std::vector<RepoPermission> translatePrivileges(
110 const std::vector<RepoPrivilege> &permissions);
119 static void updateActions(
120 const std::string &collectionType,
121 const AccessRight &permission,
122 std::vector<DBActions> &vec
141 const std::vector<RepoPermission> &permissions
150 const std::vector<RepoPrivilege> &privileges
163 return getStringField(REPO_ROLE_LABEL_DATABASE);
170 std::vector<std::pair<std::string, std::string>> getInheritedRoles()
const;
178 return getStringField(REPO_ROLE_LABEL_ROLE);
185 std::vector<RepoPrivilege> getPrivileges()
const;
193 return getPrivilegesMapped(getPrivileges());
196 static std::unordered_map<std::string, RepoPrivilege>
197 getPrivilegesMapped(
const std::vector<RepoPrivilege> &ps);
205 return translatePrivileges(getPrivileges());
216 std::vector<DBActions> getActions(
RepoBSON actionArr)
const;
Definition: repo_bson_role.h:37
Definition: repo_connection_pool_mongo.h:32
std::unordered_map< std::string, RepoPrivilege > getPrivilegesMapped() const
Definition: repo_bson_role.h:191
std::string getName() const
Definition: repo_bson_role.h:176
std::vector< RepoPermission > getProjectAccessRights() const
Definition: repo_bson_role.h:203
Definition: repo_bson.h:53
Definition: repo_bson_role.h:30
std::string getDatabase() const
Definition: repo_bson_role.h:161
Definition: repo_bson_role.h:45