Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-657

Support URI encoded characters in passwords

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.9.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      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:

      See: https://github.com/bobthecow/genghis/issues/125

            Assignee:
            tyler@10gen.com Tyler Brock
            Reporter:
            bobthecow Justin Hileman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: