diff options
author | Tim Hinderliter <tim@opscode.com> | 2009-10-27 23:47:37 -0700 |
---|---|---|
committer | Tim Hinderliter <tim@opscode.com> | 2009-10-27 23:47:37 -0700 |
commit | eda2b502133b23dc8f90eba2654d19e87a63140a (patch) | |
tree | 60c3c7d6bea1121fa9a622a6e970007de6141171 /lib/mixlib/authentication/signatureverification.rb | |
parent | 0da38ff7dcbf95e6527a5a7c25408b757f584f2d (diff) | |
download | mixlib-authentication-eda2b502133b23dc8f90eba2654d19e87a63140a.tar.gz |
fix issues with cookbook uploading by encoding/authenticating more kinds of File form input
Diffstat (limited to 'lib/mixlib/authentication/signatureverification.rb')
-rw-r--r-- | lib/mixlib/authentication/signatureverification.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/mixlib/authentication/signatureverification.rb b/lib/mixlib/authentication/signatureverification.rb index ca65c21..c9f4076 100644 --- a/lib/mixlib/authentication/signatureverification.rb +++ b/lib/mixlib/authentication/signatureverification.rb @@ -32,19 +32,23 @@ module Mixlib @signing_description = headers[:x_ops_sign].chomp @user_id = headers[:x_ops_userid].chomp @timestamp = headers[:x_ops_timestamp].chomp - @request_signature = headers[:authorization].chomp.gsub!(/\n\t/,"\n") + @request_signature = headers[:authorization].chomp.gsub(/\n\t/,"\n") @host = headers[:host].chomp @content_hash = headers[:x_ops_content_hash].chomp @user_secret = user_lookup - - file_param = request.params["file"] + # Any file that's included in the request is hashed if it's there. Otherwise, + # we hash the body. Look for files by looking for objects that respond to + # the read call. + file_param = request.params.values.find { |value| value.respond_to?(:read) } @hashed_body = if file_param Mixlib::Authentication::Log.debug "Digesting file_param: '#{file_param.inspect}'" if file_param.respond_to?(:has_key?) tempfile = file_param[:tempfile] digester.hash_file(tempfile) + elsif file_param.respond_to?(:read) + digester.hash_file(file_param) else digester.hash_body(file_param) end @@ -54,7 +58,7 @@ module Mixlib digester.hash_body(body) end - Mixlib::Authentication::Log.debug "Authenticating user : #{user_id}, User secret is: #{@user_secret}, Request signature is :\n#{@request_signature}, Hashed Body is #{@hashed_body}" + Mixlib::Authentication::Log.debug "Authenticating user : #{user_id}, User secret is : #{@user_secret}, Request signature is :\n#{@request_signature}, Auth HTTP header is :\n#{headers[:authorization]}, Hashed Body is : #{@hashed_body}" #BUGBUG Not doing anything with the signing description yet [cb] parse_signing_description |