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

Add URI encoding to mongo auth parameters #986

Merged
merged 4 commits into from
Mar 17, 2016
Merged

Commits on Mar 16, 2016

  1. Add URI encoding to mongo auth parameters

    The mongodb driver requires auth values be URI encoded:
    mongodb/node-mongodb-native@0440630
    
    This uses node's built-in url module to encode the auth portion, by
    parsing and re-formatting it, which causes special characters to get URI
    encoded properly:
    https://nodejs.org/api/url.html#url_escaped_characters
    
    This is all a bit silly since mongodb just takes our passed uri, and
    runs it through the same url parser again, but not before explicitly
    erroring on '@' characters in the uri.
    
    This is similiar to #148 (reverted by #297), but with much less code,
    and hopefully less breakage. Also, note that `uri_decode_auth` is no
    longer needed. That was removed in the above referenced
    node-mongodb-native commit.
    
    I've tested this on usernames and passwords with @, !, +, and a space.
    
    Presumably this would also work with usernames and passwords that are
    already URI encoded (since parseUrl will simply unescape it, and
    formatUrl will escape it again).
    bgw committed Mar 16, 2016
    Configuration menu
    Copy the full SHA
    a30c817 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    81f3a79 View commit details
    Browse the repository at this point in the history
  3. Fix failing tests for uri encoding auth

    This uses a *slightly* patched version of node's uri module to allow
    commas and colons in hostnames, which causes the parsed representation
    of replica sets to be less-awful.
    
    Hostname are still somewhat broken in this representation, because we
    have an array of hosts expressed as a list, but this is the
    minimum-effort solution to getting format to be able to reprint a parsed
    replica set correctly.
    
    I understand that we probably don't want to merge this (for a lot of
    reasons), but at least this shows exactly where the issue is, and yields
    some useful discussion.
    bgw committed Mar 16, 2016
    Configuration menu
    Copy the full SHA
    836582f View commit details
    Browse the repository at this point in the history
  4. Move mongoUrl to src/vendor

    And add a README to src/vendor
    bgw committed Mar 16, 2016
    Configuration menu
    Copy the full SHA
    530fad5 View commit details
    Browse the repository at this point in the history