Skip to content

Commit

Permalink
Revert "SERVER-91165: Investigate missing authorization check for _is…
Browse files Browse the repository at this point in the history
…… (#23576)

GitOrigin-RevId: a5b4fadb08450a8f55818ce0bf900288e8356636
  • Loading branch information
XueruiFa authored and MongoDB Bot committed Jun 17, 2024
1 parent 2867d18 commit fa7e48c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
11 changes: 0 additions & 11 deletions jstests/auth/lib/commands_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -5193,17 +5193,6 @@ export const authCommandsLib = {
},
]
},
{
testname: "_isSelf",
command: {_isSelf: 1},
testcases: [
{
runOnDb: adminDbName,
roles: {__system: 1},
privileges: [{resource: {cluster: true}, actions: ["internal"]}],
},
]
},
{
testname: "insert",
command: {insert: "foo", documents: [{data: 5}]},
Expand Down
17 changes: 6 additions & 11 deletions src/mongo/db/commands/isself.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/admission/execution_admission_context.h"
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/resource_pattern.h"
#include "mongo/db/commands.h"
#include "mongo/db/database_name.h"
#include "mongo/db/operation_context.h"
Expand Down Expand Up @@ -72,15 +69,13 @@ class IsSelfCommand : public BasicCommand {
return "{ _isSelf : 1 } INTERNAL ONLY";
}

Status checkAuthForOperation(OperationContext* opCtx,
const DatabaseName& dbName,
const BSONObj&) const override {
AuthorizationSession* authzSession = AuthorizationSession::get(opCtx->getClient());
if (!authzSession->isAuthorizedForActionsOnResource(
ResourcePattern::forClusterResource(dbName.tenantId()), ActionType::internal)) {
return {ErrorCodes::Unauthorized, "unauthorized for _isSelf command"};
}
bool requiresAuth() const override {
return false;
}

Status checkAuthForOperation(OperationContext*,
const DatabaseName&,
const BSONObj&) const override {
return Status::OK();
}

Expand Down

0 comments on commit fa7e48c

Please sign in to comment.