[SERVER-37520] "too many users are authenticated" after getSiblingDB() and auth() Created: 09/Oct/18  Updated: 09/Oct/18  Resolved: 09/Oct/18

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.0.1, 4.0.2
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Daniel Smedegaard Buus [X] Assignee: Nick Brewer
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-32064 A logical session id should be includ... Closed
Operating System: ALL
Steps To Reproduce:

This is how I fare with MongoDB 4.0:

 ~$ mongo mongodb://daniel:mahpass@127.0.0.1:27017/admin
{{ mongo $MONGO_URI/admin}}
{{ MongoDB shell version v4.0.2}}
{{ connecting to: mongodb://127.0.0.1:27017/admin}}
{{ MongoDB server version: 4.0.2}}
{{ > var mother = db.getSiblingDB('mother')}}
{{ > mother.auth(}}{{

{ user: 'daniel', pwd: 'mahpass' }

}})
{{ 1}}
{{ > mother.sites.find()}}
{{ Error: error: {}}
{{ "ok" : 0,}}
{{ "errmsg" : "too many users are authenticated",}}
{{ "code" : 13,}}
{{ "codeName" : "Unauthorized"}}
{{ }}}
{{ >}}

Participants:

 Description   

With MongoDB versions 4 (4.0.1 and 4.0.2 tested), I cannot switch to another db, authenticate, and operate with that db. In MongoDB 3.6, I can successfully do this:

~$ mongo mongodb://daniel:mahpass@127.0.0.1:27017/admin
{{ MongoDB shell version v3.6.7}}
{{ connecting to: mongodb://127.0.0.1:27017/admin}}
{{ MongoDB server version: 3.6.7}}
{{ > var mother = db.getSiblingDB('mother')}}
{{ > mother.auth(}}{{

{ user: 'daniel', pwd: 'mahpass' }

}})
{{ 1}}
{{ > mother.sites.find()}}{{

{ "_id" : ObjectId("54b1d0a26629edca9cbef6c3"), "client" : "Dev", "dbName" : "mother", "domain" : "mother.localhost", "licenses" : 0, "name" : "Mother" }

}}

>

My user was created on the admin database first, with "dbOwner" and "userAdminAnyDatabase" rights, and then on the "mother" database with "dbOwner" rights.

In other words, these are two different users, one on each db.

Googling the error, I only get four hits, one in Chinese, and the remaining I cannot see how are related. I've searched through the 4.0 changes, and cannot find any documented change that would cause this restriction — if indeed it is a restriction? Maybe this isn't a bug, and it's just me misbehaving?

Thanks

Daniel



 Comments   
Comment by Nick Brewer [ 09/Oct/18 ]

Daniel Smedegaard Buus This behavior is indeed expected - by design, logical sessions cannot have more than one user authenticated on a single connection. The fix to prevent this behavior is detailed here: SERVER-32064

This change will make it into the 3.6 branch in version 3.6.9.

-Nick

Comment by Daniel Smedegaard Buus [X] [ 09/Oct/18 ]

This may be worth noting. I get the same error even if not accessing the sibling db:

MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 4.0.2
> show dbs
admin 0.000GB
config 0.000GB
mother 0.002GB
local 0.000GB
tmp-scaffold-migration 0.002GB
> db.getSiblingDB('mother').auth({ user: 'daniel', pwd: 'mahpass' })
1
> show dbs
2018-10-09T13:14:09.643+0200 E QUERY [js] Error: listDatabases failed:

{ "ok" : 0, "errmsg" : "too many users are authenticated", "code" : 13, "codeName" : "Unauthorized" }

:
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:67:1
shellHelper.show@src/mongo/shell/utils.js:876:19
shellHelper@src/mongo/shell/utils.js:766:15
@(shellhelp2):1:1

Comment by Daniel Smedegaard Buus [X] [ 09/Oct/18 ]

And here's the other one:

~$ mongo mongodb://daniel:mahpass@127.0.0.1:27017/admin
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 4.0.2
> var mother = db.getSiblingDB('mother')
> mother.auth({ user: 'daniel', pwd: 'mahpass' })
1
> mother.sites.find()
Error: error:

{ "ok" : 0, "errmsg" : "too many users are authenticated", "code" : 13, "codeName" : "Unauthorized" }

>

Comment by Daniel Smedegaard Buus [X] [ 09/Oct/18 ]

Okay, there's something wrong with the editor here — my "preformatted" text is clearly converted to randomness. Also, I don't see an edit link here, so I'm adding comment instead. Here's the first block that I tried to preformat:

~$ mongo mongodb://daniel:mahpass@127.0.0.1:27017/admin
MongoDB shell version v3.6.7
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 3.6.7
> var mother = db.getSiblingDB('mother')
> mother.auth({ user: 'daniel', pwd: 'mahpass' })
1
> mother.sites.find()

{ "_id" : ObjectId("54b1d0a26629edca9cbef6c3"), "client" : "Dev", "dbName" : "mother", "domain" : "mother.localhost", "licenses" : 0, "name" : "Mother" }

>

Generated at Thu Feb 08 04:46:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.