diff options
author | Cheahuychou Mao <mao.cheahuychou@gmail.com> | 2020-12-15 22:27:48 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-04 22:32:00 +0000 |
commit | 43ddd286a7ceddc548d9518a315de59234f699e7 (patch) | |
tree | 49b41fb236b6f287d060dfc827f1e9ddf876bbb5 /src/mongo/db/commands/tenant_migration_donor_cmds.cpp | |
parent | f012be046c8a16fe80ca3c08ee19a48931feb696 (diff) | |
download | mongo-43ddd286a7ceddc548d9518a315de59234f699e7.tar.gz |
SERVER-53020 Ensure only the atlasAdmin user can run donorStartMigration and donorForgetMigration
Diffstat (limited to 'src/mongo/db/commands/tenant_migration_donor_cmds.cpp')
-rw-r--r-- | src/mongo/db/commands/tenant_migration_donor_cmds.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp index 658f1733c54..a4a838277b3 100644 --- a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp +++ b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp @@ -27,6 +27,7 @@ * it in the license file. */ +#include "mongo/db/auth/authorization_session.h" #include "mongo/db/commands.h" #include "mongo/db/commands/tenant_migration_donor_cmds_gen.h" #include "mongo/db/repl/primary_only_service.h" @@ -97,7 +98,13 @@ public: return response; } - void doCheckAuthorization(OperationContext* opCtx) const {} + void doCheckAuthorization(OperationContext* opCtx) const { + uassert(ErrorCodes::Unauthorized, + "Unauthorized", + AuthorizationSession::get(opCtx->getClient()) + ->isAuthorizedForActionsOnResource(ResourcePattern::forClusterResource(), + ActionType::runTenantMigration)); + } private: bool supportsWriteConcern() const override { @@ -162,7 +169,13 @@ public: } private: - void doCheckAuthorization(OperationContext* opCtx) const {} + void doCheckAuthorization(OperationContext* opCtx) const { + uassert(ErrorCodes::Unauthorized, + "Unauthorized", + AuthorizationSession::get(opCtx->getClient()) + ->isAuthorizedForActionsOnResource(ResourcePattern::forClusterResource(), + ActionType::runTenantMigration)); + } bool supportsWriteConcern() const override { return false; |