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/dbtests/cursor_manager_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/dbtests/cursor_manager_test.cpp')
-rw-r--r-- | src/mongo/dbtests/cursor_manager_test.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/mongo/dbtests/cursor_manager_test.cpp b/src/mongo/dbtests/cursor_manager_test.cpp index 6abd9844de7..6505a64bea0 100644 --- a/src/mongo/dbtests/cursor_manager_test.cpp +++ b/src/mongo/dbtests/cursor_manager_test.cpp @@ -441,7 +441,7 @@ TEST_F(CursorManagerTestCustomOpCtx, LogicalSessionIdOnOperationCtxTest) { // Cursors created on an op ctx with a session id have a session id. { - auto lsid = LogicalSessionId::gen(); + auto lsid = makeLogicalSessionIdForTest(); auto opCtx2 = _queryServiceContext->makeOperationContext(lsid); auto pinned2 = makeCursor(opCtx2.get()); @@ -469,7 +469,7 @@ TEST_F(CursorManagerTestCustomOpCtx, CursorsWithoutSessions) { */ TEST_F(CursorManagerTestCustomOpCtx, OneCursorWithASession) { // Add a cursor with a session to the cursor manager. - auto lsid = LogicalSessionId::gen(); + auto lsid = makeLogicalSessionIdForTest(); auto opCtx = _queryServiceContext->makeOperationContext(lsid); auto pinned = makeCursor(opCtx.get()); @@ -501,7 +501,7 @@ TEST_F(CursorManagerTestCustomOpCtx, OneCursorWithASession) { */ TEST_F(CursorManagerTestCustomOpCtx, MultipleCursorsWithSameSession) { // Add two cursors on the same session to the cursor manager. - auto lsid = LogicalSessionId::gen(); + auto lsid = makeLogicalSessionIdForTest(); auto opCtx = _queryServiceContext->makeOperationContext(lsid); auto pinned = makeCursor(opCtx.get()); auto pinned2 = makeCursor(opCtx.get()); @@ -510,7 +510,7 @@ TEST_F(CursorManagerTestCustomOpCtx, MultipleCursorsWithSameSession) { auto cursorId2 = pinned2.getCursor()->cursorid(); // Retrieve all sessions - set should contain just lsid. - stdx::unordered_set<LogicalSessionId, LogicalSessionId::Hash> lsids; + stdx::unordered_set<LogicalSessionId, LogicalSessionIdHash> lsids; useCursorManager()->appendActiveSessions(&lsids); ASSERT_EQ(lsids.size(), size_t(1)); ASSERT(lsids.find(lsid) != lsids.end()); @@ -541,8 +541,8 @@ TEST_F(CursorManagerTestCustomOpCtx, MultipleCursorsWithSameSession) { * Test a manager with multiple cursors running inside of different sessions. */ TEST_F(CursorManagerTestCustomOpCtx, MultipleCursorsMultipleSessions) { - auto lsid1 = LogicalSessionId::gen(); - auto lsid2 = LogicalSessionId::gen(); + auto lsid1 = makeLogicalSessionIdForTest(); + auto lsid2 = makeLogicalSessionIdForTest(); CursorId cursor1; CursorId cursor2; |