本文整理汇总了C++中NamespaceString::getTargetNSForListIndexes方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceString::getTargetNSForListIndexes方法的具体用法?C++ NamespaceString::getTargetNSForListIndexes怎么用?C++ NamespaceString::getTargetNSForListIndexes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceString
的用法示例。
在下文中一共展示了NamespaceString::getTargetNSForListIndexes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAuthForKillCursors
Status AuthorizationSession::checkAuthForKillCursors(const NamespaceString& ns,
long long cursorID) {
// See implementation comments in checkAuthForGetMore(). This method looks very similar.
if (ns.isListCollectionsCursorNS()) {
if (!isAuthorizedForActionsOnResource(ResourcePattern::forDatabaseName(ns.db()),
ActionType::killCursors)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized to kill listCollections cursor on "
<< ns.ns());
}
} else if (ns.isListIndexesCursorNS()) {
NamespaceString targetNS = ns.getTargetNSForListIndexes();
if (!isAuthorizedForActionsOnNamespace(targetNS, ActionType::killCursors)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized to kill listIndexes cursor on "
<< ns.ns());
}
} else {
if (!isAuthorizedForActionsOnNamespace(ns, ActionType::killCursors)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized to kill cursor on " << ns.ns());
}
}
return Status::OK();
}
示例2: checkAuthForKillCursors
Status AuthorizationSession::checkAuthForKillCursors(const NamespaceString& ns,
long long cursorID) {
// See implementation comments in checkAuthForGetMore(). This method looks very similar.
// SERVER-20364 Check for find or killCursor privileges until we have a way of associating
// a cursor with an owner.
if (ns.isListCollectionsCursorNS()) {
if (!(isAuthorizedForActionsOnResource(ResourcePattern::forDatabaseName(ns.db()),
ActionType::killCursors) ||
isAuthorizedForActionsOnResource(ResourcePattern::forDatabaseName(ns.db()),
ActionType::listCollections))) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized to kill listCollections cursor on "
<< ns.ns());
}
} else if (ns.isListIndexesCursorNS()) {
NamespaceString targetNS = ns.getTargetNSForListIndexes();
if (!(isAuthorizedForActionsOnNamespace(targetNS, ActionType::killCursors) ||
isAuthorizedForActionsOnNamespace(targetNS, ActionType::listIndexes))) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized to kill listIndexes cursor on "
<< ns.ns());
}
} else {
if (!(isAuthorizedForActionsOnNamespace(ns, ActionType::killCursors) ||
isAuthorizedForActionsOnNamespace(ns, ActionType::find))) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized to kill cursor on " << ns.ns());
}
}
return Status::OK();
}
示例3: checkAuthForGetMore
Status AuthorizationSession::checkAuthForGetMore(const NamespaceString& ns, long long cursorID) {
// "ns" can be in one of three formats: "listCollections" format, "listIndexes" format, and
// normal format.
if (ns.isListCollectionsCursorNS()) {
// "ns" is of the form "<db>.$cmd.listCollections". Check if we can perform the
// listCollections action on the database resource for "<db>".
if (!isAuthorizedForActionsOnResource(ResourcePattern::forDatabaseName(ns.db()),
ActionType::listCollections)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized for listCollections getMore on "
<< ns.ns());
}
} else if (ns.isListIndexesCursorNS()) {
// "ns" is of the form "<db>.$cmd.listIndexes.<coll>". Check if we can perform the
// listIndexes action on the "<db>.<coll>" namespace.
NamespaceString targetNS = ns.getTargetNSForListIndexes();
if (!isAuthorizedForActionsOnNamespace(targetNS, ActionType::listIndexes)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized for listIndexes getMore on " << ns.ns());
}
} else {
// "ns" is a regular namespace string. Check if we can perform the find action on it.
if (!isAuthorizedForActionsOnNamespace(ns, ActionType::find)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized for getMore on " << ns.ns());
}
}
return Status::OK();
}
示例4: checkAuthForGetMore
Status AuthorizationSession::checkAuthForGetMore(const NamespaceString& ns,
long long cursorID,
bool hasTerm) {
// "ns" can be in one of three formats: "listCollections" format, "listIndexes" format, and
// normal format.
if (ns.isListCollectionsCursorNS()) {
// "ns" is of the form "<db>.$cmd.listCollections". Check if we can perform the
// listCollections action on the database resource for "<db>".
if (!isAuthorizedForActionsOnResource(ResourcePattern::forDatabaseName(ns.db()),
ActionType::listCollections)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized for listCollections getMore on "
<< ns.ns());
}
} else if (ns.isListIndexesCursorNS()) {
// "ns" is of the form "<db>.$cmd.listIndexes.<coll>". Check if we can perform the
// listIndexes action on the "<db>.<coll>" namespace.
NamespaceString targetNS = ns.getTargetNSForListIndexes();
if (!isAuthorizedForActionsOnNamespace(targetNS, ActionType::listIndexes)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized for listIndexes getMore on " << ns.ns());
}
} else {
// "ns" is a regular namespace string. Check if we can perform the find action on it.
if (!isAuthorizedForActionsOnNamespace(ns, ActionType::find)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized for getMore on " << ns.ns());
}
}
// Only internal clients (such as other nodes in a replica set) are allowed to use
// the 'term' field in a getMore operation. Use of this field could trigger changes
// in the receiving server's replication state and should be protected.
if (hasTerm &&
!isAuthorizedForActionsOnResource(ResourcePattern::forClusterResource(),
ActionType::internal)) {
return Status(ErrorCodes::Unauthorized,
str::stream() << "not authorized for getMore with term on " << ns.ns());
}
return Status::OK();
}