Skip to content

Apply basic authentication from URI - #477

Closed
janko wants to merge 1 commit into
httprb:masterfrom
janko:apply-basic-auth-from-uri
Closed

janko wants to merge 1 commit into
httprb:masterfrom
janko:apply-basic-auth-from-uri

Conversation

@janko

@janko janko commented May 28, 2018 •

Copy link
Copy Markdown
Member

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
Copy Markdown

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

Comment thread spec/lib/http_spec.rb
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
Copy Markdown

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

janko commented May 28, 2018 •

Copy link
Copy Markdown
Member Author

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

tarcieri commented May 28, 2018 •

Copy link
Copy Markdown
Member

@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