diff options
author | Spencer T Brody <spencer@10gen.com> | 2013-08-12 18:18:08 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2013-08-19 17:03:51 -0400 |
commit | e8a98c47fcf80829adae349c09efa1f6e2e1d9af (patch) | |
tree | d84947d9f8dd2acc90fbf3a819b39d84e8921916 /src/mongo/db/auth/authorization_session.cpp | |
parent | 4140e3743026af40d83b29f10cfbc6d7cd8505fa (diff) | |
download | mongo-e8a98c47fcf80829adae349c09efa1f6e2e1d9af.tar.gz |
SERVER-9518 Reload User if User has been invalidated
Diffstat (limited to 'src/mongo/db/auth/authorization_session.cpp')
-rw-r--r-- | src/mongo/db/auth/authorization_session.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/auth/authorization_session.cpp b/src/mongo/db/auth/authorization_session.cpp index 6c89fbbef84..5358d5c90f0 100644 --- a/src/mongo/db/auth/authorization_session.cpp +++ b/src/mongo/db/auth/authorization_session.cpp @@ -356,7 +356,21 @@ namespace { it != _authenticatedUsers.end(); ++it) { User* user = *it; - // TODO(spencer): Handle if the user has been invalidated. + if (!user->isValid()) { + // Need to release and re-acquire user if it's been invalidated. + UserName name = user->getName(); + + _authenticatedUsers.removeByDBName(name.getDB()); + getAuthorizationManager().releaseUser(user); + + Status status = getAuthorizationManager().acquireUser(name, &user); + if (!status.isOK()) { + return Status(ErrorCodes::Unauthorized, + mongoutils::str::stream() << "Re-acquiring invalidated user " + "failed due to: " << status.reason()); + } + _authenticatedUsers.add(user); + } for (int i = 0; i < static_cast<int>(boost::size(resourceSearchList)); ++i) { ActionSet userActions = user->getActionsForResource(resourceSearchList[i]); |