diff options
author | Daniel DeLeo <dan@opscode.com> | 2012-08-02 11:49:35 -0700 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2012-08-02 11:49:35 -0700 |
commit | a47a14e569b5c0b12c476498dfb7a79d11e0bc8a (patch) | |
tree | 9afb9212140629babb539bb4afeb32ba353d551c /lib/mixlib/authentication/signedheaderauth.rb | |
parent | 696df3e0122900fc95c0355d09c7b15fc7be7ee1 (diff) | |
download | mixlib-authentication-a47a14e569b5c0b12c476498dfb7a79d11e0bc8a.tar.gz |
make proto version switching work correctly with signing_object
Diffstat (limited to 'lib/mixlib/authentication/signedheaderauth.rb')
-rw-r--r-- | lib/mixlib/authentication/signedheaderauth.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/mixlib/authentication/signedheaderauth.rb b/lib/mixlib/authentication/signedheaderauth.rb index 4ee7f98..f37471d 100644 --- a/lib/mixlib/authentication/signedheaderauth.rb +++ b/lib/mixlib/authentication/signedheaderauth.rb @@ -80,7 +80,7 @@ module Mixlib # compute the signature from the request, using the looked-up user secret # ====Parameters # private_key<OpenSSL::PKey::RSA>:: user's RSA private key. - def sign(private_key, sign_algorithm=DEFAULT_SIGN_ALGORITHM, sign_version=DEFAULT_PROTO_VERSION) + def sign(private_key, sign_algorithm=algorithm, sign_version=proto_version) # Our multiline hash for authorization will be encoded in multiple header # lines - X-Ops-Authorization-1, ... (starts at 1, not 0!) header_hash = { @@ -136,12 +136,12 @@ module Mixlib # ====Parameters # # - def canonicalize_request(algorithm=DEFAULT_SIGN_ALGORITHM, version=DEFAULT_PROTO_VERSION) - unless SUPPORTED_ALGORITHMS.include?(algorithm) && SUPPORTED_VERSIONS.include?(version) - raise AuthenticationError, "Bad algorithm '#{algorithm}' (allowed: #{SUPPORTED_ALGORITHMS.inspect}) or version '#{version}' (allowed: #{SUPPORTED_VERSIONS.inspect})" + def canonicalize_request(sign_algorithm=algorithm, sign_version=proto_version) + unless SUPPORTED_ALGORITHMS.include?(sign_algorithm) && SUPPORTED_VERSIONS.include?(sign_version) + raise AuthenticationError, "Bad algorithm '#{sign_algorithm}' (allowed: #{SUPPORTED_ALGORITHMS.inspect}) or version '#{sign_version}' (allowed: #{SUPPORTED_VERSIONS.inspect})" end - canonical_x_ops_user_id = canonicalize_user_id(user_id, version) + canonical_x_ops_user_id = canonicalize_user_id(user_id, sign_version) "Method:#{http_method.to_s.upcase}\nHashed Path:#{digester.hash_string(canonical_path)}\nX-Ops-Content-Hash:#{hashed_body}\nX-Ops-Timestamp:#{canonical_time}\nX-Ops-UserId:#{canonical_x_ops_user_id}" end @@ -186,7 +186,7 @@ module Mixlib include SignedHeaderAuth def proto_version - self[:proto_version] or DEFAULT_PROTO_VERSION + (self[:proto_version] or DEFAULT_PROTO_VERSION).to_s end end |