python - mongoengine using Authentication Database -
i not sure how connect mongodb database uses authentication database mongoengine.
on command prompt need mongo hostname:27017/myapp -u "test" -p "test" --authenticationdatabase admin
, don't see i'd pass argument mongoengine use admin database auth connect myapp database models?
i believe it's explained in pymongo guide:
https://api.mongodb.com/python/current/examples/authentication.html
>>> pymongo import mongoclient >>> client = mongoclient('example.com') >>> db = client.the_database >>> db.authenticate('user', 'password', source='source_database')
and found pull request added mongoengine:
https://github.com/mongoengine/mongoengine/pull/590/files
it looks add authentication_source
argument connect
connect(authentication_source='admin')
. it'd nice if better documented.
http://docs.mongoengine.org/apireference.html?highlight=authentication_source
according mongoengine connecting guide, connect()
method support uri style connections. i.e.
connect( 'project1' host='mongodb://username:password@host1:port1/databasename' )
in sense, can specify authentication source database below:
"mongodb://username:password@host1:port1/database?authsource=source_database"
see mongodb connection string uri more mongodb uri examples. authentication options through connection string
Comments
Post a Comment