diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2018-12-12 15:24:36 -0500 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2018-12-13 16:56:47 -0500 |
commit | e09ecae708d96a608abdbf99bc961824ed9ca0c9 (patch) | |
tree | a364c50ec45b731c3df165e0b9291d0fc610bbc0 /src/mongo/db/auth/authorization_manager_impl.cpp | |
parent | b13a3dc314f05a719b45d793a6c14a9e2ac8be0c (diff) | |
download | mongo-e09ecae708d96a608abdbf99bc961824ed9ca0c9.tar.gz |
SERVER-38533 Convert src/mongo/db/auth/authorization_manager_impl.cpp to IDL
Diffstat (limited to 'src/mongo/db/auth/authorization_manager_impl.cpp')
-rw-r--r-- | src/mongo/db/auth/authorization_manager_impl.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/mongo/db/auth/authorization_manager_impl.cpp b/src/mongo/db/auth/authorization_manager_impl.cpp index 5973ac9b00e..88368a9fd17 100644 --- a/src/mongo/db/auth/authorization_manager_impl.cpp +++ b/src/mongo/db/auth/authorization_manager_impl.cpp @@ -46,6 +46,7 @@ #include "mongo/crypto/mechanism_scram.h" #include "mongo/db/auth/action_set.h" #include "mongo/db/auth/address_restriction.h" +#include "mongo/db/auth/authorization_manager_impl_parameters_gen.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/auth/authorization_session_impl.h" #include "mongo/db/auth/authz_manager_external_state.h" @@ -113,15 +114,9 @@ MONGO_INITIALIZER_GENERAL(SetupInternalSecurityUser, return exceptionToStatus(); } -MONGO_EXPORT_STARTUP_SERVER_PARAMETER(authorizationManagerCacheSize, int, 100); - -class PinnedUserSetParameter final : public ServerParameter { +class PinnedUserSetParameter { public: - PinnedUserSetParameter() - : ServerParameter( - ServerParameterSet::getGlobal(), "authorizationManagerPinnedUsers", true, true) {} - - void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) override { + void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) const { BSONArrayBuilder sub(b.subarrayStart(name)); for (const auto& username : _userNames) { BSONObjBuilder nameObj(sub.subobjStart()); @@ -130,7 +125,7 @@ public: } } - Status set(const BSONElement& newValueElement) override { + Status set(const BSONElement& newValueElement) { if (newValueElement.type() == String) { return setFromString(newValueElement.valuestrsafe()); } else if (newValueElement.type() == Array) { @@ -146,7 +141,7 @@ public: } stdx::unique_lock<stdx::mutex> lk(_mutex); - std::swap(_userNames, out); + _userNames = std::move(out); auto authzManager = _authzManager; if (!authzManager) { return Status::OK(); @@ -162,7 +157,7 @@ public: } } - Status setFromString(const std::string& str) override { + Status setFromString(const std::string& str) { std::vector<std::string> strList; splitStringDelim(str, &strList, ','); @@ -185,9 +180,10 @@ public: return Status::OK(); } - stdx::unique_lock<stdx::mutex> lk(_mutex); - std::swap(out, _userNames); - lk.unlock(); + { + stdx::lock_guard<stdx::mutex> lk(_mutex); + _userNames = std::move(out); + } authzManager->invalidateUserCache(Client::getCurrent()->getOperationContext()); return Status::OK(); @@ -222,6 +218,21 @@ const auto inUserManagementCommandsFlag = OperationContext::declareDecoration<bo } // namespace +int authorizationManagerCacheSize; + +void AuthorizationManagerPinnedUsersHooks::appendBson(OperationContext* opCtx, + BSONObjBuilder* out, + StringData name) { + return authorizationManagerPinnedUsers.append(opCtx, *out, std::string(name)); +} + +Status AuthorizationManagerPinnedUsersHooks::fromBson(const BSONElement& newValue) { + return authorizationManagerPinnedUsers.set(newValue); +} + +Status AuthorizationManagerPinnedUsersHooks::fromString(StringData str) { + return authorizationManagerPinnedUsers.setFromString(std::string(str)); +} MONGO_REGISTER_SHIM(AuthorizationManager::create)()->std::unique_ptr<AuthorizationManager> { return std::make_unique<AuthorizationManagerImpl>(); |