OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
MongoRoleFunctions.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <cstdint>
5#include <iostream>
6#include <vector>
7#include <bsoncxx/json.hpp>
8#include <bsoncxx/types.hpp>
9#include <mongocxx/client.hpp>
10#include <mongocxx/stdx.hpp>
11#include <mongocxx/uri.hpp>
12#include <mongocxx/instance.hpp>
13#include <bsoncxx/builder/stream/helpers.hpp>
14#include <bsoncxx/builder/stream/document.hpp>
15#include <bsoncxx/builder/stream/array.hpp>
16
17#include "MongoConstants.h"
18#include "Group.h"
19
20using bsoncxx::builder::stream::close_array;
21using bsoncxx::builder::stream::close_document;
22using bsoncxx::builder::stream::document;
23using bsoncxx::builder::stream::finalize;
24using bsoncxx::builder::stream::open_array;
25using bsoncxx::builder::stream::open_document;
26using bsoncxx::document::value;
27using bsoncxx::document::view;
28using bsoncxx::document::element;
29
30
32{
33 // Function that creates the Inital Role. To be used only once!
34 bool createInitialProjectRole(mongocxx::client& adminClient);
35 bool createInitialProjectDbListCollectionsRole(mongocxx::client& adminClient);
36
37 bool createInitialUserRole(mongocxx::client& adminClient);
38 bool createInitialUserDbListCollectionsRole(mongocxx::client& adminClient);
39
40 bool createInitialGroupRole(mongocxx::client& adminClient);
41
42 bool createInitialProjectTemplatesRole(mongocxx::client& adminClient);
43 bool createInitialProjectsLargeDataRole(mongocxx::client& adminClient);
44 bool createInitialSystemDbRole(mongocxx::client& adminClient);
45 bool createInitialSettingsDbRole(mongocxx::client& adminClient);
46
47 bool createAllAccessibleRole(std::string dbName, std::string roleName, mongocxx::client& adminClient);
48
49
50 // When a new project (Collection) is created, a role for it must be created, else, nobody can access it.
51 void createProjectRole(std::string roleName, std::string collectionName, mongocxx::client& adminClient);
52
53 // When a new user is created, a role for it must be created, else, nobody can access it.
54 void createUserRole(std::string roleName, mongocxx::client& adminClient);
55 void addRoleToUserRole(std::string roleName, User& user, mongocxx::client& adminClient);
56 void addRoleToUserRole(std::string roleName, std::string userRoleName, mongocxx::client& adminClient);
57 void removeRoleFromUserRole(std::string roleName, User& user, mongocxx::client& adminClient);
58
59 // Creates a group role which has no privileges at all
60 void createGroupRole(std::string roleName, mongocxx::client& adminClient);
61
62 // Adds a role to an already existing group role to inherit
63 void addRoleToGroupRole(std::string roleName, Group& group, mongocxx::client& adminClient);
64
65 void removeRoleFromGroupRole(std::string roleName, Group& group, mongocxx::client& adminClient);
66
67 void addRoleToUser(std::string roleName, std::string username, mongocxx::client& adminClient);
68
69 void removeRoleFromUser(std::string roleName, std::string username, mongocxx::client& adminClient);
70
71
72 void removeRole(std::string roleName, mongocxx::client& adminClient);
73}
Definition Group.h:20
Definition User.h:20
Definition MongoRoleFunctions.h:32
bool createInitialProjectDbListCollectionsRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:68
void removeRole(std::string roleName, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:591
void addRoleToGroupRole(std::string roleName, Group &group, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:536
void removeRoleFromUser(std::string roleName, std::string username, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:584
bool createInitialGroupRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:221
void createGroupRole(std::string roleName, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:520
void addRoleToUserRole(std::string roleName, User &user, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:478
bool createAllAccessibleRole(std::string dbName, std::string roleName, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:297
void createProjectRole(std::string roleName, std::string collectionName, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:366
void removeRoleFromUserRole(std::string roleName, User &user, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:501
bool createInitialProjectRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:9
bool createInitialSystemDbRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:283
void createUserRole(std::string roleName, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:463
bool createInitialProjectTemplatesRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:269
bool createInitialProjectsLargeDataRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:276
bool createInitialUserDbListCollectionsRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:174
bool createInitialUserRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:115
void addRoleToUser(std::string roleName, std::string username, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:577
void removeRoleFromGroupRole(std::string roleName, Group &group, mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:556
bool createInitialSettingsDbRole(mongocxx::client &adminClient)
Definition MongoRoleFunctions.cpp:290