mongo-connector icon indicating copy to clipboard operation
mongo-connector copied to clipboard

Fix username clobbering in mongodb_uri

Open dsem opened this issue 7 years ago • 1 comments

I was unable to get mongo-connector to authenticate with mongodb as the origin using x509 auth. When calling with username on the command line, i.e.,

mongo-connector --admin-username <X.509 derived username> -m mongodb://localhost/?replicaSet=rs&authMechanism=MONGODB-X509&authSource=$external&ssl=true&ssl_certfile=/etc/pki/tls/private/bundle.pem

mongo complains mongo_connector.errors.InvalidConfiguration: Admin username specified without password.

When calling with the username as part of the mongo uri, i.e.,

mongo-connector -m mongodb://<X.509 derived username>@localhost/?replicaSet=rs&authMechanism=MONGODB-X509&authSource=$external&ssl=true&ssl_certfile=/etc/pki/tls/private/bundle.pem

the username gets clobbered by connection.copy_uri_options() and the server rejects the connection.

This PR updates connection.copy_uri_options() to not clobber usernames and passwords. I haven't tested it with anonymous or any other type of authentication, but I believe it should work.

Note, using x509 auth with mongo as the destination db does not have this bug.

dsem avatar Apr 07 '18 21:04 dsem

Experiencing the same issue with PLAIN authMechanism.

Adding some logging in the connection.copy_uri_options() results in the below: image

admosity avatar Mar 26 '19 12:03 admosity