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

Does not work against httpbin digest-auth endpoint #15

Open
HoneyryderChuck opened this issue Dec 15, 2017 · 0 comments
Open

Does not work against httpbin digest-auth endpoint #15

HoneyryderChuck opened this issue Dec 15, 2017 · 0 comments

Comments

@HoneyryderChuck
Copy link

HoneyryderChuck commented Dec 15, 2017

I've tried to use this gem against httpbin's endpoints, and either the digest header hasn't been properly generated, or I'm failing to see how to set this up:

require "net/http"
require "net/http/digest_auth"

uri = URI.parse "http://httpbin.org/digest-auth/auth/user/pass"
uri.user = "user"
uri.password = "pass"

h = Net::HTTP.new uri.host, uri.port
h.set_debug_output $stderr

req = Net::HTTP::Get.new uri.request_uri

res = h.request req

digest_auth = Net::HTTP::DigestAuth.new
auth = digest_auth.auth_header uri, res["www-authenticate"], "GET"

req = Net::HTTP::Get.new uri.request_uri
req.add_field "Authorization", auth

res = h.request req

puts
puts "passed" if res.code == "200"
puts "failed" if res.code != "200"
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

1 participant