summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/resource_pattern.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/auth/resource_pattern.h')
-rw-r--r--src/mongo/db/auth/resource_pattern.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mongo/db/auth/resource_pattern.h b/src/mongo/db/auth/resource_pattern.h
index ba04e382e00..24bc1020301 100644
--- a/src/mongo/db/auth/resource_pattern.h
+++ b/src/mongo/db/auth/resource_pattern.h
@@ -98,6 +98,27 @@ namespace mongo {
}
/**
+ * Returns true if this pattern matches on the collection name only.
+ */
+ bool isCollectionPattern() const {
+ return _matchType == matchCollectionName;
+ }
+
+ /**
+ * Returns true if this pattern matches the cluster resource only.
+ */
+ bool isClusterResourcePattern() const {
+ return _matchType == matchClusterResource;
+ }
+
+ /**
+ * Returns true if this pattern matches only any normal resource.
+ */
+ bool isAnyNormalResourcePattern() const {
+ return _matchType == matchAnyNormalResource;
+ }
+
+ /**
* Returns true if this pattern matches nothing at all.
*/
bool matchesNothing() const { return matchNever == _matchType; }
@@ -155,6 +176,22 @@ namespace mongo {
*/
const NamespaceString& ns() const { return _ns; }
+ /**
+ * Returns the database that this pattern matches.
+ *
+ * Behavior is undefined unless the pattern is of type matchDatabaseName or
+ * matchExactNamespace
+ */
+ StringData databaseToMatch() const { return _ns.db(); }
+
+ /**
+ * Returns the collection that this pattern matches.
+ *
+ * Behavior is undefined unless the pattern is of type matchCollectionName or
+ * matchExactNamespace
+ */
+ StringData collectionToMatch() const { return _ns.coll(); }
+
std::string toString() const;
inline size_t hash() const {