bool CmdSaslStart::run(OperationContext* txn, const std::string& db, BSONObj& cmdObj, int options, std::string& ignored, BSONObjBuilder& result) { Client* client = Client::getCurrent(); AuthenticationSession::set(client, std::unique_ptr<AuthenticationSession>()); std::string mechanism; if (!extractMechanism(cmdObj, &mechanism).isOK()) { return false; } SaslAuthenticationSession* session = SaslAuthenticationSession::create(AuthorizationSession::get(client), db, mechanism); std::unique_ptr<AuthenticationSession> sessionGuard(session); session->setOpCtxt(txn); Status status = doSaslStart(client, session, db, cmdObj, &result); appendCommandStatus(result, status); if (session->isDone()) { audit::logAuthentication(client, session->getMechanism(), UserName(session->getPrincipalId(), db), status.code()); } else { AuthenticationSession::swap(client, sessionGuard); } return status.isOK(); }
bool CmdSaslStart::run(OperationContext* txn, const std::string& db, BSONObj& cmdObj, int options, std::string& ignored, BSONObjBuilder& result, bool fromRepl) { ClientBasic* client = ClientBasic::getCurrent(); client->resetAuthenticationSession(NULL); SaslAuthenticationSession* session = SaslAuthenticationSession::create(client->getAuthorizationSession()); boost::scoped_ptr<AuthenticationSession> sessionGuard(session); session->setOpCtxt(txn); Status status = doSaslStart(session, db, cmdObj, &result); addStatus(status, &result); if (session->isDone()) { audit::logAuthentication( client, session->getMechanism(), UserName(session->getPrincipalId(), db), status.code()); } else { client->swapAuthenticationSession(sessionGuard); } return status.isOK(); }