diff options
author | Adi Zaimi <adizaimi@yahoo.com> | 2021-09-09 14:21:14 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-09 15:06:38 +0000 |
commit | 1181ad492b061a582c7873c8ee610b098c9076b8 (patch) | |
tree | b01c919af1c2dc437ef473feba9e811d8bf8b070 /src/mongo/db/commands/user_management_commands.cpp | |
parent | e1517972ad00351a79030fce12a62d9cee5f8cce (diff) | |
download | mongo-1181ad492b061a582c7873c8ee610b098c9076b8.tar.gz |
SERVER-58893 more commands to skip api version check
Diffstat (limited to 'src/mongo/db/commands/user_management_commands.cpp')
-rw-r--r-- | src/mongo/db/commands/user_management_commands.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index 5990af74f85..e5a43d3a7bc 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -918,6 +918,7 @@ struct UMCStdParams { static constexpr bool adminOnly = false; static constexpr bool supportsWriteConcern = true; static constexpr auto allowedOnSecondary = BasicCommand::AllowedOnSecondary::kNever; + static constexpr bool skipApiVersionCheck = false; }; // Used by {usersInfo:...} and {rolesInfo:...} @@ -925,15 +926,26 @@ struct UMCInfoParams { static constexpr bool adminOnly = false; static constexpr bool supportsWriteConcern = false; static constexpr auto allowedOnSecondary = BasicCommand::AllowedOnSecondary::kOptIn; + static constexpr bool skipApiVersionCheck = false; }; -// Used by {invalidateUserCache:...} and {_getUserCacheGeneration:...} -struct UMCCacheParams { +// Used by {invalidateUserCache:...} +struct UMCInvalidateUserCacheParams { + static constexpr bool adminOnly = false; + static constexpr bool supportsWriteConcern = false; + static constexpr auto allowedOnSecondary = BasicCommand::AllowedOnSecondary::kAlways; + static constexpr bool skipApiVersionCheck = false; +}; + +// Used by {_getUserCacheGeneration:...} +struct UMCGetUserCacheGenParams { static constexpr bool adminOnly = true; static constexpr bool supportsWriteConcern = false; static constexpr auto allowedOnSecondary = BasicCommand::AllowedOnSecondary::kAlways; + static constexpr bool skipApiVersionCheck = true; }; + template <typename RequestT, typename Params = UMCStdParams> class CmdUMCTyped : public TypedCommand<CmdUMCTyped<RequestT, Params>> { public: @@ -962,6 +974,10 @@ public: } }; + bool skipApiVersionCheck() const final { + return Params::skipApiVersionCheck; + } + bool adminOnly() const final { return Params::adminOnly; } @@ -971,6 +987,7 @@ public: } }; + class CmdCreateUser : public CmdUMCTyped<CreateUserCommand> { public: static constexpr StringData kPwdField = "pwd"_sd; @@ -2027,24 +2044,26 @@ RolesInfoReply CmdUMCTyped<RolesInfoCommand, UMCInfoParams>::Invocation::typedRu return reply; } -CmdUMCTyped<InvalidateUserCacheCommand, UMCCacheParams> cmdInvalidateUserCache; +CmdUMCTyped<InvalidateUserCacheCommand, UMCInvalidateUserCacheParams> cmdInvalidateUserCache; template <> -void CmdUMCTyped<InvalidateUserCacheCommand, UMCCacheParams>::Invocation::typedRun( +void CmdUMCTyped<InvalidateUserCacheCommand, UMCInvalidateUserCacheParams>::Invocation::typedRun( OperationContext* opCtx) { auto* authzManager = AuthorizationManager::get(opCtx->getServiceContext()); auto lk = requireReadableAuthSchema26Upgrade(opCtx, authzManager); authzManager->invalidateUserCache(opCtx); } -CmdUMCTyped<GetUserCacheGenerationCommand, UMCCacheParams> cmdGetUserCacheGeneration; +CmdUMCTyped<GetUserCacheGenerationCommand, UMCGetUserCacheGenParams> cmdGetUserCacheGeneration; + template <> GetUserCacheGenerationReply -CmdUMCTyped<GetUserCacheGenerationCommand, UMCCacheParams>::Invocation::typedRun( +CmdUMCTyped<GetUserCacheGenerationCommand, UMCGetUserCacheGenParams>::Invocation::typedRun( OperationContext* opCtx) { uassert(ErrorCodes::IllegalOperation, "_getUserCacheGeneration can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); + cmdGetUserCacheGeneration.skipApiVersionCheck(); GetUserCacheGenerationReply reply; auto* authzManager = AuthorizationManager::get(opCtx->getServiceContext()); reply.setCacheGeneration(authzManager->getCacheGeneration()); |