summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/authentication_commands.cpp
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@10gen.com>2021-04-26 23:05:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-26 23:28:42 +0000
commit6212e50e73dd032b448a514fe6893c6490a28a9f (patch)
treeecd108b0e736caa4bc066b7b9eea08e5f735f7fa /src/mongo/db/commands/authentication_commands.cpp
parentc36e5a0496fe1e0ba962bb112b4a4b0ccd5b2608 (diff)
downloadmongo-6212e50e73dd032b448a514fe6893c6490a28a9f.tar.gz
SERVER-56266 First logout command emits a deprecation warning
Diffstat (limited to 'src/mongo/db/commands/authentication_commands.cpp')
-rw-r--r--src/mongo/db/commands/authentication_commands.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp
index 4e953d09a82..9edc8bcc4d7 100644
--- a/src/mongo/db/commands/authentication_commands.cpp
+++ b/src/mongo/db/commands/authentication_commands.cpp
@@ -139,6 +139,24 @@ private:
SecureRandom _random;
} cmdGetNonce;
+/**
+ * A simple class to track "global" parameters related to the logout command.
+ */
+class LogoutCommandState {
+public:
+ /**
+ * Marks the command as invoked and returns if it was previously invoked.
+ */
+ bool markAsInvoked() {
+ return _hasBeenInvoked.swap(true);
+ }
+
+private:
+ AtomicWord<bool> _hasBeenInvoked{false};
+};
+
+auto getLogoutCommandState = ServiceContext::declareDecoration<LogoutCommandState>();
+
class CmdLogout : public TypedCommand<CmdLogout> {
public:
using Request = LogoutCommand;
@@ -168,6 +186,14 @@ public:
static constexpr auto kAdminDB = "admin"_sd;
static constexpr auto kLocalDB = "local"_sd;
void typedRun(OperationContext* opCtx) {
+ auto& logoutState = getLogoutCommandState(opCtx->getServiceContext());
+ auto hasBeenInvoked = logoutState.markAsInvoked();
+ if (!hasBeenInvoked) {
+ LOGV2_WARNING(5626600,
+ "The logout command has been deprecated, clients should end their "
+ "session instead");
+ }
+
auto dbname = request().getDbName();
auto* as = AuthorizationSession::get(opCtx->getClient());