diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mixlib/authentication/digester.rb | 4 | ||||
-rw-r--r-- | lib/mixlib/authentication/signedheaderauth.rb | 10 |
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/mixlib/authentication/digester.rb b/lib/mixlib/authentication/digester.rb index 8628d53..f826b4c 100644 --- a/lib/mixlib/authentication/digester.rb +++ b/lib/mixlib/authentication/digester.rb @@ -27,9 +27,7 @@ module Mixlib def hash_file(f, digest = OpenSSL::Digest::SHA1) digester = digest.new buf = "" - while f.read(16384, buf) - digester.update buf - end + digester.update buf while f.read(16384, buf) ::Base64.encode64(digester.digest).chomp end diff --git a/lib/mixlib/authentication/signedheaderauth.rb b/lib/mixlib/authentication/signedheaderauth.rb index ab8d989..f107170 100644 --- a/lib/mixlib/authentication/signedheaderauth.rb +++ b/lib/mixlib/authentication/signedheaderauth.rb @@ -263,23 +263,23 @@ module Mixlib # A Struct-based value object that contains the necessary information to # generate a request signature. `SignedHeaderAuth.signing_object()` # provides a more convenient interface to the constructor. - class SigningObject < Struct.new(:http_method, :path, :body, :host, + SigningObject = Struct.new(:http_method, :path, :body, :host, :timestamp, :user_id, :file, :proto_version, - :headers) + :headers) do include SignedHeaderAuth def proto_version - (self[:proto_version] || DEFAULT_PROTO_VERSION).to_s + (self[:proto_version] || SignedHeaderAuth::DEFAULT_PROTO_VERSION).to_s end def server_api_version key = (self[:headers] || {}).keys.select do |k| - k.downcase == "x-ops-server-api-version" + k.casecmp("x-ops-server-api-version").zero? end.first if key self[:headers][key] else - DEFAULT_SERVER_API_VERSION + SignedHeaderAuth::DEFAULT_SERVER_API_VERSION end end end |