DoubleCiti / mongodb-migrations

A database migration tool for MongoDB
GNU General Public License v3.0
71 stars 43 forks source link

MongoDB authentication #31

Open Pei116 opened 4 years ago

Pei116 commented 4 years ago

https://github.com/DoubleCiti/mongodb-migrations/blob/3d9a029f7f1bcc90f96c3845bb65b957ed19d2a9/mongodb_migrations/cli.py#L111

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.

darth30joker commented 4 years ago

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

darth30joker commented 4 years ago

@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?

HitLuca commented 3 years ago

@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

darth30joker commented 3 years ago

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