DoubleCiti/mongodb-migrations

MongoDB authentication

Opened this issue · 4 comments

if url and database and user is not None: #provide auth_database in url (mongodb://mongohostname:27017/auth_database)

We have several other cases which require authentication. It seems username and password are set only when both url and database are specified. But, for example, we sometimes have only host and username/password authentication.
Let me know if you need more clarification.

@Pei116 ye, it makes sense. Let me think about it, will provide a fix later.

@Pei116 Just a follow up on this. You don't provide any database for migration, what database should we use then? Or is it for multiple databases?

@david30xie I am also encountering this issue: in my case, db connection is made using the database+username+password elements, but the code won't use username and password (third if branch). Couldn't we just set username and password to the empty string if the username is None? In that case you won't use credentials unless given, and can set username and password every time you create a MongoClient.

Also, this issue is present in the BaseMigration initialization, so I would recommend unifying them in a single function

Hi @HitLuca thank you for reporting this. I'll fix this asap.