summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-07-21 16:56:06 -0700
committerDaniel DeLeo <dan@opscode.com>2010-07-21 16:56:06 -0700
commit7c06e5feeed09da7c7938007ed52edb0e0c28da2 (patch)
tree942306a77bbcc9b30d546f0605a4ec16b1500c1d
parent20caa069c28abd12fc2bd62606474fdba7362d97 (diff)
downloadmixlib-authentication-7c06e5feeed09da7c7938007ed52edb0e0c28da2.tar.gz
[CHEF-761] rewrite delegation using Forwardable
-rw-r--r--lib/mixlib/authentication/signatureverification.rb51
1 files changed, 18 insertions, 33 deletions
diff --git a/lib/mixlib/authentication/signatureverification.rb b/lib/mixlib/authentication/signatureverification.rb
index ec09f12..c6f68a3 100644
--- a/lib/mixlib/authentication/signatureverification.rb
+++ b/lib/mixlib/authentication/signatureverification.rb
@@ -18,6 +18,7 @@
#
require 'net/http'
+require 'forwardable'
require 'mixlib/authentication'
require 'mixlib/authentication/http_authentication_request'
require 'mixlib/authentication/signedheaderauth'
@@ -28,7 +29,23 @@ module Mixlib
end
class SignatureVerification
- MANDATORY_HEADERS = [:x_ops_sign, :x_ops_userid, :x_ops_timestamp, :host, :x_ops_content_hash]
+ extend Forwardable
+
+ def_delegator :@auth_request, :http_method
+
+ def_delegator :@auth_request, :path
+
+ def_delegator :auth_request, :signing_description
+
+ def_delegator :@auth_request, :user_id
+
+ def_delegator :@auth_request, :timestamp
+
+ def_delegator :@auth_request, :host
+
+ def_delegator :@auth_request, :request_signature
+
+ def_delegator :@auth_request, :content_hash
include Mixlib::Authentication::SignedHeaderAuth
@@ -114,38 +131,6 @@ module Mixlib
end
end
- def http_method
- auth_request.http_method
- end
-
- def path
- auth_request.path
- end
-
- def signing_description
- auth_request.signing_description
- end
-
- def user_id
- auth_request.user_id
- end
-
- def timestamp
- auth_request.timestamp
- end
-
- def host
- auth_request.host
- end
-
- def request_signature
- auth_request.request_signature
- end
-
- def content_hash
- auth_request.content_hash
- end
-
def verify_signature
candidate_block = canonicalize_request
request_decrypted_block = @user_secret.public_decrypt(Base64.decode64(request_signature))