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

url decode username and password #385

Closed
travisghansen opened this issue Oct 26, 2017 · 4 comments
Closed

url decode username and password #385

travisghansen opened this issue Oct 26, 2017 · 4 comments

Comments

@travisghansen
Copy link

travisghansen commented Oct 26, 2017

From what I can tell the library doesn't support a : (colon) in the username. I'm encoding it in my configuration and it still appears to be failing. Any tips/thoughts?

@squaremo
Copy link
Collaborator

If you supply a username and password in the URL, like amqps://foo:bar@localhost, it'll interpret the bit before the first colon as the username. If you need to include a colon in the username, you can use an object instead of a string, as described under http://www.squaremobius.net/amqp.node/channel_api.html#connect.

@travisghansen
Copy link
Author

@squaremo unfortunately I'm using this library via a higher-level library (nodered node) and don't really have access to that. Shouldn't a properly encoded set of credentials work (a la curl, etc)?

@squaremo
Copy link
Collaborator

The trouble is that url.parse decodes the auth value (user:password), so the value that amqplib sees has already had any percent-encoded colons ('%3A') turned into ':', and any unencoded colons ':' are also ':'. There's no way to tell which were part of the username.

There are a couple of options for improving the situation. From Node 7.0 onwards, there's a different URL parser available in the standard lib which supplies the username and password separately (and presumably deals with percent encoding properly on the way). Failing that, or for older Node, I guess someone could write a URL parser, at least for the first part of the URL.

@travisghansen
Copy link
Author

Wow awesome! I'll have to wait for a new version to hit before trying this out probably if you want some testing tried on it.

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

2 participants