Methods

Files

Net::HTTPHeader

Public Instance Methods

digest_auth(user, password, response) click to toggle source
    # File lib/httparty/net_digest_auth.rb, line 6
 6:     def digest_auth(user, password, response)
 7:       response['www-authenticate'] =~ /^(\w+) (.*)/
 8: 
 9:       params = {}
10:       $2.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }
11:       params.merge!("cnonce" => Digest::MD5.hexdigest("%x" % (Time.now.to_i + rand(65535))))
12: 
13:       a_1 = Digest::MD5.hexdigest("#{user}:#{params['realm']}:#{password}")
14:       a_2 = Digest::MD5.hexdigest("#{@method}:#{@path}")
15: 
16:       request_digest = Digest::MD5.hexdigest(
17:         [a_1, params['nonce'], "0", params['cnonce'], params['qop'], a_2].join(":")
18:       )
19: 
20:       header = [
21:         %(Digest username="#{user}"),
22:         %(realm="#{params['realm']}"),
23:         %(qop="#{params['qop']}"),
24:         %(uri="#{@path}"),
25:         %(nonce="#{params['nonce']}"),
26:         %(nc="0"),
27:         %(cnonce="#{params['cnonce']}"),
28:         %(opaque="#{params['opaque']}"),
29:         %(response="#{request_digest}")
30:       ]
31: 
32:       @header['Authorization'] = header
33:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.