Skip to content

Commit

Permalink
factored out the header bundle building to the auth lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Brown committed Apr 21, 2009
1 parent dda200d commit 9409c4c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lib/opscode/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,11 @@ def request(method, url, options={}, limit=10)

if options[:authenticate]
ts = options[:timestamp] || Time.now.utc.iso8601
sign_obj = Mixlib::SignedHeaderAuth.signing_object(:http_method=>method,:body=>options[:payload]||"",:timestamp=>ts,:user_id=>options[:user_id])

signing_description = 'version=1.0;algorithm=sha256'
signed = sign_obj.sign(options[:user_secret])
hashed_body = sign_obj.hash_body
options[:headers].merge!( {
:x_ops_sign=>signing_description,
:x_ops_userid=>options[:user_id],
:x_ops_timestamp=>ts,
:x_ops_content_hash=>hashed_body,
:authorization=>signed,
})
body = options[:payload] || ""
sign_obj = Mixlib::SignedHeaderAuth.signing_object(:http_method=>method,:body=>body,:timestamp=>ts,:user_id=>options[:user_id])
options[:headers].merge!(sign_obj.sign(options[:user_secret]))
end

req = RestClient::Request.new(
:method => method,
:url => url,
Expand Down

0 comments on commit 9409c4c

Please sign in to comment.