summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/privilege.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/auth/privilege.h')
-rw-r--r--src/mongo/db/auth/privilege.h67
1 files changed, 35 insertions, 32 deletions
diff --git a/src/mongo/db/auth/privilege.h b/src/mongo/db/auth/privilege.h
index 1009172a30c..da6b054e012 100644
--- a/src/mongo/db/auth/privilege.h
+++ b/src/mongo/db/auth/privilege.h
@@ -36,47 +36,50 @@
namespace mongo {
- class Privilege;
- typedef std::vector<Privilege> PrivilegeVector;
+class Privilege;
+typedef std::vector<Privilege> PrivilegeVector;
+/**
+ * A representation of the permission to perform a set of actions on a resource.
+ */
+class Privilege {
+public:
/**
- * A representation of the permission to perform a set of actions on a resource.
+ * Adds "privilegeToAdd" to "privileges", de-duping "privilegeToAdd" if the vector already
+ * contains a privilege on the same resource.
+ *
+ * This method is the preferred way to add privileges to privilege vectors.
*/
- class Privilege {
- public:
- /**
- * Adds "privilegeToAdd" to "privileges", de-duping "privilegeToAdd" if the vector already
- * contains a privilege on the same resource.
- *
- * This method is the preferred way to add privileges to privilege vectors.
- */
- static void addPrivilegeToPrivilegeVector(PrivilegeVector* privileges,
- const Privilege& privilegeToAdd);
-
+ static void addPrivilegeToPrivilegeVector(PrivilegeVector* privileges,
+ const Privilege& privilegeToAdd);
- Privilege() {};
- Privilege(const ResourcePattern& resource, const ActionType& action);
- Privilege(const ResourcePattern& resource, const ActionSet& actions);
- ~Privilege() {}
- const ResourcePattern& getResourcePattern() const { return _resource; }
+ Privilege(){};
+ Privilege(const ResourcePattern& resource, const ActionType& action);
+ Privilege(const ResourcePattern& resource, const ActionSet& actions);
+ ~Privilege() {}
- const ActionSet& getActions() const { return _actions; }
+ const ResourcePattern& getResourcePattern() const {
+ return _resource;
+ }
- void addActions(const ActionSet& actionsToAdd);
- void removeActions(const ActionSet& actionsToRemove);
+ const ActionSet& getActions() const {
+ return _actions;
+ }
- // Checks if the given action is present in the Privilege.
- bool includesAction(const ActionType& action) const;
- // Checks if the given actions are present in the Privilege.
- bool includesActions(const ActionSet& actions) const;
+ void addActions(const ActionSet& actionsToAdd);
+ void removeActions(const ActionSet& actionsToRemove);
- BSONObj toBSON() const;
+ // Checks if the given action is present in the Privilege.
+ bool includesAction(const ActionType& action) const;
+ // Checks if the given actions are present in the Privilege.
+ bool includesActions(const ActionSet& actions) const;
- private:
+ BSONObj toBSON() const;
- ResourcePattern _resource;
- ActionSet _actions; // bitmask of actions this privilege grants
- };
+private:
+ ResourcePattern _resource;
+ ActionSet _actions; // bitmask of actions this privilege grants
+};
-} // namespace mongo
+} // namespace mongo