我不确定如何连接到使用mongoengine使用验证数据库的mongodb数据库。使用验证数据库的mongoengine
在命令提示符下,我需要做mongo hostname:27017/myApp -u "test" -p "test" --authenticationDatabase admin
,但我没有看到我将它作为mongoengine的参数传递到哪里,所以我使用admin数据库进行身份验证,但连接到我的模型的myApp数据库?
我相信这是它的PyMongo引导In公司解释说:
https://api.mongodb.com/python/current/examples/authentication.html
>>> from pymongo import MongoClient
>>> client = MongoClient('example.com')
>>> db = client.the_database
>>> db.authenticate('user', 'password', source='source_database')
我发现添加这mongoengine拉入请求:
https://github.com/MongoEngine/mongoengine/pull/590/files
它看起来像你刚刚添加authentication_source
作为connect
的参数,如connect(authentication_source='admin')
。如果它有更好的文档记录,那会很好。
http://docs.mongoengine.org/apireference.html?highlight=authentication_source
这不是我要求的,认证源需要明确说明,所以你发送的东西不会工作 – Rob
@Rob更新。我已经从链接中提取信息,让您通过URI指定验证源。 –