4
* Copyright (C) 2012 10gen Inc.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Affero General Public License, version 3,
8
* as published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#include "mongo/db/commands/find_and_modify.h"
24
#include "mongo/db/auth/action_set.h"
25
#include "mongo/db/auth/action_type.h"
26
#include "mongo/db/auth/privilege.h"
27
#include "mongo/db/jsobj.h"
30
namespace find_and_modify {
32
void addPrivilegesRequiredForFindAndModify(const std::string& dbname,
33
const BSONObj& cmdObj,
34
std::vector<Privilege>* out) {
35
bool update = cmdObj["update"].trueValue();
36
bool upsert = cmdObj["upsert"].trueValue();
37
bool remove = cmdObj["remove"].trueValue();
40
actions.addAction(ActionType::find);
42
actions.addAction(ActionType::update);
45
actions.addAction(ActionType::insert);
48
actions.addAction(ActionType::remove);
50
std::string ns = dbname + '.' + cmdObj.firstElement().valuestr();
51
out->push_back(Privilege(ns, actions));
54
} // namespace find_and_modify