Skip to content

Commit a3fb626

Browse files
committed
PSMDB-1922 Require authorization for auditGetOptions command
1 parent cba193b commit a3fb626

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/mongo/db/audit/audit_commands.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,19 @@ class AuditGetOptionsCommand : public AuditCommand {
136136
"Example: { auditGetOptions: 1 }";
137137
}
138138

139-
Status checkAuthForOperation(OperationContext*,
140-
const DatabaseName&,
139+
bool adminOnly() const override {
140+
return true;
141+
}
142+
143+
Status checkAuthForOperation(OperationContext* opCtx,
144+
const DatabaseName& dbName,
141145
const BSONObj&) const override {
146+
auto* as = AuthorizationSession::get(opCtx->getClient());
147+
if (!as->isAuthorizedForActionsOnResource(
148+
ResourcePattern::forClusterResource(dbName.tenantId()), ActionType::getParameter)) {
149+
return {ErrorCodes::Unauthorized, "unauthorized"};
150+
}
151+
142152
return Status::OK();
143153
}
144154

0 commit comments

Comments
 (0)