diff options
author | Jason Carey <jcarey@argv.me> | 2017-07-21 11:54:18 -0400 |
---|---|---|
committer | Jason Carey <jcarey@argv.me> | 2017-07-26 15:53:42 -0400 |
commit | edfe3f3b1276ef3598b1af673d088e6b5c4b3ad5 (patch) | |
tree | 08f0efcdb6100dc315cf5e9ac98c0c6261be928d /src/mongo/db/session_test.cpp | |
parent | cb36a96d7c96cf1b24c7ef3b8b086cfc04c77642 (diff) | |
download | mongo-edfe3f3b1276ef3598b1af673d088e6b5c4b3ad5.tar.gz |
SERVER-30298 Add UserDigest LogicalSessionID
Inclusion of a sha256 digest of the full username to the logical session
id (in addition to the current guid) is necessary to fully disambiguate
logical sessions in degraded clusters (when the authoritative record for
a session is unreachable).
Semantics for the uid are as follows:
session creation via startSession()
* Sessions can only be created with one, and only one, user authenticated
* The composite key is created from a guid created on the spot, as well
as the digest of the currently auth'd username
* Only the session guid is returned to the user
* This prevents outside users from attempting to send back a value
we'd have to check. It's preferable to decorate the guid with the
user digest per command, rather than having to check a value the user
might send.
session use for a command
* Sessions are passed via the lsid top level field in any command
* Sessions are only meaningful for commands which requireAuth. For
sessions which don't require auth, we strip session information from the
command at parse time
* Session ids are passed as an object, which can optionally include the
username digest
* It is illegal to pass the username digest unless the currently
auth'd user has the impersonate privilege (the __system user does).
This enables sessions on shard servers via mongos
Diffstat (limited to 'src/mongo/db/session_test.cpp')
-rw-r--r-- | src/mongo/db/session_test.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/mongo/db/session_test.cpp b/src/mongo/db/session_test.cpp index b52068b7fb4..902a632a1ee 100644 --- a/src/mongo/db/session_test.cpp +++ b/src/mongo/db/session_test.cpp @@ -111,7 +111,7 @@ private: }; TEST_F(SessionTest, CanCreateNewSessionEntry) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; Session txnState(sessionId); @@ -141,7 +141,7 @@ TEST_F(SessionTest, CanCreateNewSessionEntry) { } TEST_F(SessionTest, StartingOldTxnShouldAssert) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; Session txnState(sessionId); @@ -154,7 +154,7 @@ TEST_F(SessionTest, StartingOldTxnShouldAssert) { } TEST_F(SessionTest, StartingNewSessionWithCompatibleEntryInStorage) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; const Timestamp origTs(985, 15); @@ -193,7 +193,7 @@ TEST_F(SessionTest, StartingNewSessionWithCompatibleEntryInStorage) { } TEST_F(SessionTest, StartingNewSessionWithOlderEntryInStorageShouldUpdateEntry) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); TxnNumber txnNum = 20; const Timestamp origTs(985, 15); @@ -232,7 +232,7 @@ TEST_F(SessionTest, StartingNewSessionWithOlderEntryInStorageShouldUpdateEntry) } TEST_F(SessionTest, StartingNewSessionWithNewerEntryInStorageShouldAssert) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); TxnNumber txnNum = 20; const Timestamp origTs(985, 15); @@ -271,7 +271,7 @@ TEST_F(SessionTest, StartingNewSessionWithNewerEntryInStorageShouldAssert) { } TEST_F(SessionTest, StoreOpTime) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; const Timestamp ts1(100, 42); @@ -337,7 +337,7 @@ TEST_F(SessionTest, StoreOpTime) { } TEST_F(SessionTest, CanBumpTransactionIdIfNewer) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); TxnNumber txnNum = 20; const Timestamp ts1(100, 42); @@ -397,7 +397,7 @@ TEST_F(SessionTest, CanBumpTransactionIdIfNewer) { } TEST_F(SessionTest, StartingNewSessionWithDroppedTableShouldAssert) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; const auto& ns = NamespaceString::kSessionTransactionsTableNamespace; @@ -413,7 +413,7 @@ TEST_F(SessionTest, StartingNewSessionWithDroppedTableShouldAssert) { } TEST_F(SessionTest, SaveTxnProgressShouldAssertIfTableIsDropped) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; const Timestamp ts1(100, 42); @@ -433,14 +433,14 @@ TEST_F(SessionTest, SaveTxnProgressShouldAssertIfTableIsDropped) { } TEST_F(SessionTest, TwoSessionsShouldBeIndependent) { - const auto sessionId1 = LogicalSessionId::gen(); + const auto sessionId1 = makeLogicalSessionIdForTest(); const TxnNumber txnNum1 = 20; const Timestamp ts1(1903, 42); Session txnState1(sessionId1); txnState1.begin(opCtx(), txnNum1); - const auto sessionId2 = LogicalSessionId::gen(); + const auto sessionId2 = makeLogicalSessionIdForTest(); const TxnNumber txnNum2 = 300; const Timestamp ts2(671, 5); @@ -498,7 +498,7 @@ TEST_F(SessionTest, TwoSessionsShouldBeIndependent) { } TEST_F(SessionTest, CheckStatementExecuted) { - const auto sessionId = LogicalSessionId::gen(); + const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; const StmtId stmtId = 5; |