-
Notifications
You must be signed in to change notification settings - Fork 46
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
[BUG] Client doesn't handle basic auth passwords with special characters in url correctly #60
Comments
Let me take a look on this. Will get back. |
The password |
Correct, I believe that the library should decode the password before trying to use it for authentication. I realize I left a detail out of my initial bug report: If I were to try specifying the password without URL encoding like Additionally, I can use |
Ruby default parser doesn't seem to want to decode the password.
The RFC says "Within the user and password field, any ":", "@", or "/" must be encoded."
So this doesn't decode the password either. It seems like in most libraries unencoding is left to the caller, e.g. in addressable:
Calling decode first would be a breaking change. I vote to leave things as is. Note that using URLs with username/password in them is deprecated in the RFC, because this will log the user's password. That's obviously a bad security practice, so I would get rid of any code that passes username/password into the URL. |
Agree with @dblock , this will be breaking change. We should leave the decoding to caller. |
@NoahCarnahan Do you feel strongly otherwise? Otherwise let's close this? |
I agree that the default ruby parser doesn’t do any decoding, but I think it’s the responsibility of I recognize that passing username and password in the url isn’t ideal, but I do wonder if this library also can’t handle escaped characters in the path part of the url, which I imagine could come up with certain index names (I haven’t tested this). Ultimately, I’m not a contributor to this project, so I’m not going to push too hard for the change, but I do feel that the current behavior of the library doesn’t handle all valid RFC 1738 urls correctly, which seems like a bug to me. |
@NoahCarnahan If you have some spare time, add a few RSpec tests and document current behavior (e.g. a test that checks that encoded path part is decoded)? This way we will know what we are changing, if we are and it will help the next person. |
It looks like the password part is as per the RFC and is also a deprecated practice. I propose we close this issue and if anyone finds an issue with the url parsing, we can create a new issue. |
I think we should implement some specs and document this behavior before we close it. |
What is the bug?
It seems like
OpenSearch::Client
doesn't handle hosts/urls that contain passwords in the url with special characters correctly. When making requests with one of these urls, I get an "Unauthorized" error. I believe the problem is that__parse_host
doesn't decode the special characters.How can one reproduce the bug?
Example code snippet:
I can however get around this problem by passing a hash in the url parameter that does the decoding myself:
What is the expected behavior?
I expect that passwords embedded in the url with standard url encoding should not cause authentication errors
What is your host/environment?
The text was updated successfully, but these errors were encountered: