summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands/cluster_user_management_commands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/commands/cluster_user_management_commands.cpp')
-rw-r--r--src/mongo/s/commands/cluster_user_management_commands.cpp48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/mongo/s/commands/cluster_user_management_commands.cpp b/src/mongo/s/commands/cluster_user_management_commands.cpp
index bab53eef228..843b31c80a4 100644
--- a/src/mongo/s/commands/cluster_user_management_commands.cpp
+++ b/src/mongo/s/commands/cluster_user_management_commands.cpp
@@ -269,42 +269,40 @@ public:
CmdUMCInfo<UsersInfoCommand, UsersInfoReply> cmdUsersInfo;
CmdUMCInfo<RolesInfoCommand, RolesInfoReply> cmdRolesInfo;
-class CmdInvalidateUserCache : public BasicCommand {
+class CmdInvalidateUserCache : public TypedCommand<CmdInvalidateUserCache> {
public:
- CmdInvalidateUserCache() : BasicCommand("invalidateUserCache") {}
+ using Request = InvalidateUserCacheCommand;
- AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
- return AllowedOnSecondary::kAlways;
- }
+ class Invocation final : public InvocationBase {
+ public:
+ using InvocationBase::InvocationBase;
- virtual bool adminOnly() const {
- return true;
- }
+ void typedRun(OperationContext* opCtx) {
+ const auto authzManager = AuthorizationManager::get(opCtx->getServiceContext());
+ authzManager->invalidateUserCache(opCtx);
+ }
+ private:
+ bool supportsWriteConcern() const final {
+ return false;
+ }
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
- return false;
- }
+ void doCheckAuthorization(OperationContext* opCtx) const final {
+ auth::checkAuthForTypedCommand(opCtx->getClient(), request());
+ }
- std::string help() const override {
- return "Invalidates the in-memory cache of user information";
- }
+ NamespaceString ns() const override {
+ return NamespaceString(request().getDbName(), "");
+ }
+ };
- virtual Status checkAuthForCommand(Client* client,
- const std::string& dbname,
- const BSONObj& cmdObj) const {
- return auth::checkAuthForInvalidateUserCacheCommand(client);
+ AllowedOnSecondary secondaryAllowed(ServiceContext*) const final {
+ return AllowedOnSecondary::kAlways;
}
- bool run(OperationContext* opCtx,
- const string& dbname,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) {
- const auto authzManager = AuthorizationManager::get(opCtx->getServiceContext());
- authzManager->invalidateUserCache(opCtx);
+ bool adminOnly() const final {
return true;
}
-
} cmdInvalidateUserCache;
/**