-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
The Ruby driver MongoClient.from_uri does not currently support URI encoded characters in passwords (and other URI components, I imagine). This makes it a bit difficult to connect via URI when there's an '@' in a password
c = Mongo::MongoClient.from_uri('mongodb://foo:b%40r@localhost/admin') c.database_names # or anything else requiring auth... # => Mongo::AuthenticationError: Failed to authenticate user 'foo' on db 'admin'
It looks like the bug is in Mongo::URIParser:
auth = Mongo::URIParser.new('mongodb://foo:b%40r@localhost/admin').auths.first auth[:password] # => 'b%20r'
Compared to creating the auth directly:
auth = Mongo::MongoClient.new.add_auth('admin', 'foo', 'b@r', nil) auth[:password] # => 'b@r'
This does appear to be a common problem with many other drivers as well: