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

Apply basic authentication from URI #477

Closed
wants to merge 1 commit into from

Conversation

janko
Copy link
Member

@janko janko commented May 28, 2018

URIs can have basic authentication defined in them, for example:

https://janko:secret@example.com

Currently username and password in URIs are ignored. This change modifies HTTP::Client to automatically detect these options and applies basic authentication.

Closes #476

URIs can have basic authentication defined in them, for example

  https://janko:secret@example.com

Currently username and password in URIs are ignored. This change
modifies HTTP::Client to automatically detect these options and applies
basic authentication.
@HoneyryderChuck
Copy link

Is this RFC-compliant? I didn't know that setting a username and password in the URI should be interpreted as basic auth.

uri.password = "secret"

headers = JSON.parse(HTTP.get("#{uri}/headers").to_s)
expect(headers["Authorization"]).to match(%r{^Basic [A-Za-z0-9+/]+=*$})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually a constant value, maybe better hardcode it?

@janko
Copy link
Member Author

janko commented May 28, 2018

Is this RFC-compliant? I didn't know that setting a username and password in the URI should be interpreted as basic auth.

Hmm, that's a good question. According to the HTTP Authentication MDN page, doing this is deprecated.

screen shot 2018-05-28 at 16 46 15

Feel free to close the PR and the issue then 😄

@tarcieri
Copy link
Member

tarcieri commented May 28, 2018

@HoneyryderChuck interesting question... perhaps we should discuss on #476 (Edit: LOL, @janko-m beat me to exactly what I wanted to say)

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

Successfully merging this pull request may close these issues.

4 participants