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

user and pass should be decoded when parsing #9

Closed
CallMeLaNN opened this issue Jan 15, 2017 · 0 comments
Closed

user and pass should be decoded when parsing #9

CallMeLaNN opened this issue Jan 15, 2017 · 0 comments

Comments

@CallMeLaNN
Copy link

CallMeLaNN commented Jan 15, 2017

Consider this connection strings:

mongodb://CN=nodejs-api.host.com,OU=IT,O=Org,L=City,ST=State,C=MY@host.com:57017/dbName
mongodb://CN%3Dnodejs-api.host.com%2COU%3DIT%2CO%3DOrg%2CL%3DCity%2CST%3DState%2CC%3DMY@host.com:57017/dbName

The user is x.509 certificate subject compatible with RFC2253.

The first URI is invalid because the user is not encoded and conflict with comma separator for replica set. The later one is correct but muri does not decode it. So it simply return CN%3Dnodejs-api.host.com%2COU%3DIT%2CO%3DOrg%2CL%3DCity%2CST%3DState%2CC%3DMY to the caller, which will then pass to the MongoDb server before rejecting with something like user not found because you know, the un-encoded and encoded string is never the same.

Please consider using decodeURIComponent() to support not only special character in password but also to verify client certificate in TLS/SSL connection.

The MongoDb native driver for NodeJs also ask to encode it.

Related to #6

vkarpov15 added a commit to Automattic/mongoose that referenced this issue Jan 16, 2017
OmarElgabry added a commit to OmarElgabry/chat.io that referenced this issue Feb 22, 2017
The username and password in the database URI may contain characters
that breaks (has special meaning). If so, they should be encoded, Why?
Because any operation done by Mongoose (like parsing or splitting the
URI) may result in error since the URI contains characters that has
special meaning.

Therefore we need to encode the username an password in the URI and send
URI to Mongoose, which in turn will decode both the username and
password right before sending the URI to the MongoDb server.

- Issue: aheckmann/muri#9
- replica set:
https://docs.mongodb.com/manual/reference/glossary/#term-replica-set
OmarElgabry added a commit to OmarElgabry/chat.io that referenced this issue Feb 22, 2017
The username and password in the database URI may contain characters
that break (has special meaning). If so, they should be encoded, Why?
Because any operation done by Mongoose (like parsing or splitting the
URI) may result in error since the URI contains characters that has
special meaning.

Therefore we need to encode the username an password in the URI and send
URI to Mongoose, which in turn will decode both the username and
password (so Mongoose expects them to be encoded already) right before
sending the URI to the MongoDb server.

- Issue: aheckmann/muri#9
- replica set:
https://docs.mongodb.com/manual/reference/glossary/#term-replica-set
dmfila added a commit to dmfila/chat.io that referenced this issue Jul 20, 2019
The username and password in the database URI may contain characters
that break (has special meaning). If so, they should be encoded, Why?
Because any operation done by Mongoose (like parsing or splitting the
URI) may result in error since the URI contains characters that has
special meaning.

Therefore we need to encode the username an password in the URI and send
URI to Mongoose, which in turn will decode both the username and
password (so Mongoose expects them to be encoded already) right before
sending the URI to the MongoDb server.

- Issue: aheckmann/muri#9
- replica set:
https://docs.mongodb.com/manual/reference/glossary/#term-replica-set
naumanjadev added a commit to naumanjadev/Chat-App that referenced this issue Mar 14, 2024
The username and password in the database URI may contain characters
that break (has special meaning). If so, they should be encoded, Why?
Because any operation done by Mongoose (like parsing or splitting the
URI) may result in error since the URI contains characters that has
special meaning.

Therefore we need to encode the username an password in the URI and send
URI to Mongoose, which in turn will decode both the username and
password (so Mongoose expects them to be encoded already) right before
sending the URI to the MongoDb server.

- Issue: aheckmann/muri#9
- replica set:
https://docs.mongodb.com/manual/reference/glossary/#term-replica-set
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

No branches or pull requests

1 participant