diff options
author | James Wahlin <james@mongodb.com> | 2017-07-03 15:33:36 -0400 |
---|---|---|
committer | James Wahlin <james@mongodb.com> | 2017-07-25 12:24:49 -0400 |
commit | 5dcaad5f137eebc1915c0fc7b5078da4aa86f915 (patch) | |
tree | 3994b41708bce7cf5cbc5b7c9ba422db77f9bfb3 /src/mongo/db/pipeline/document_source_facet.cpp | |
parent | 079763d2cd06776edf81f3ecf6c32ab66d1742ec (diff) | |
download | mongo-5dcaad5f137eebc1915c0fc7b5078da4aa86f915.tar.gz |
SERVER-29371 DocumentSource classes should provide auth requirements
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_facet.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document_source_facet.cpp b/src/mongo/db/pipeline/document_source_facet.cpp index 222d78e69c3..992f3daac11 100644 --- a/src/mongo/db/pipeline/document_source_facet.cpp +++ b/src/mongo/db/pipeline/document_source_facet.cpp @@ -118,12 +118,24 @@ vector<pair<string, vector<BSONObj>>> extractRawPipelines(const BSONElement& ele std::unique_ptr<DocumentSourceFacet::LiteParsed> DocumentSourceFacet::LiteParsed::parse( const AggregationRequest& request, const BSONElement& spec) { std::vector<LiteParsedPipeline> liteParsedPipelines; + for (auto&& rawPipeline : extractRawPipelines(spec)) { liteParsedPipelines.emplace_back( AggregationRequest(request.getNamespaceString(), rawPipeline.second)); } - return std::unique_ptr<DocumentSourceFacet::LiteParsed>( - new DocumentSourceFacet::LiteParsed(std::move(liteParsedPipelines))); + + PrivilegeVector requiredPrivileges; + for (auto&& pipeline : liteParsedPipelines) { + + // A correct isMongos flag is only required for DocumentSourceCurrentOp which is disallowed + // in $facet pipelines. + const bool unusedIsMongosFlag = false; + Privilege::addPrivilegesToPrivilegeVector(&requiredPrivileges, + pipeline.requiredPrivileges(unusedIsMongosFlag)); + } + + return stdx::make_unique<DocumentSourceFacet::LiteParsed>(std::move(liteParsedPipelines), + std::move(requiredPrivileges)); } stdx::unordered_set<NamespaceString> DocumentSourceFacet::LiteParsed::getInvolvedNamespaces() |