Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix username clobbering in mongodb_uri #808

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dsem
Copy link

@dsem dsem commented Apr 7, 2018

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.

@admosity
Copy link

Experiencing the same issue with PLAIN authMechanism.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants