Reputation: 1621
I am using Python-Eve with a MongoDB instance with authorization enabled, so I need to provide user/pass credentials in settings.py
to properly initialize Python-Eve API.
If used the MONGO_URI
global configuration setting, to declare the database endpoint as described here it works just right:
MONGO_URI = 'mongodb://<someuser>:<somepass>@<host>/<auth_db>'
But if I try to use the other possible way according to Eve documentation, which is to declare at settings.py, individual settings for each part or the URI, like this:
MONGO_HOST = <host>
MONGO_PORT = 27017
MONGO_DBNAME = <mongo_db>
MONGO_USERNAME = <someuser>
MONGO_PASSWORD = <somepass>
MONGO_AUTHDBNAME = <auth_db>
I get an error like the one below:
pymongo.errors.OperationFailure: command SON([('saslStart', 1), ('mechanism', 'SCRAM-SHA-1'), ('autoAuthorize', 1), ('payload', Binary(b'n,,n=root,r=MzcxMTQ1MTM3MTExNDYwNg==', 0))]) on namespace testapp.$cmd failed: Authentication failed.
What is missing to make it work this way?
Upvotes: 2
Views: 1517
Reputation: 6576
MONGO_AUTHDBNAME
is useful for some old MongoDB authentication schemes which are now deprecated. For more information see the original pull request discussion.
Upvotes: 1
Reputation: 1621
OK I figured out what was wrong to make it work. The auth database that is used to check credentials is the same as MONGO_DBNAME
, not MONGO_AUTH_DBNAME
value. So in my example the users must exist in the <mongo_db>
database, not in the <auth_db>
as I was expecting.
But then, what is the purpose of MONGO_AUTHDBNAME
setting?
Upvotes: 4