Skip to content

Fix username clobbering in mongodb_uri#808

Open
dsem wants to merge 1 commit into
yougov:masterfrom
dsem:fix-x509-authentication
Open

Fix username clobbering in mongodb_uri#808
dsem wants to merge 1 commit into
yougov:masterfrom
dsem:fix-x509-authentication

Conversation

@dsem

@dsem dsem commented Apr 7, 2018

Copy link
Copy Markdown

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
Copy Markdown

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