diff options
author | Daniel DeLeo <dan@opscode.com> | 2010-07-21 19:58:11 -0700 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2010-07-21 19:58:11 -0700 |
commit | 48df6b6096cef7cb0c366525d82e20befcf8e345 (patch) | |
tree | 7f7527773ecf4c0b4bbd4291e6cfc9d8c898d9e7 /lib/mixlib/authentication/signatureverification.rb | |
parent | 4d07b23047d17e42eb4630cbc758cc2f671ee986 (diff) | |
download | mixlib-authentication-48df6b6096cef7cb0c366525d82e20befcf8e345.tar.gz |
[CHEF-761] initialize with the request to access normalized headers
* Can now create the signature verification object w/ the request and
then access values computed by the HTTPAuthenticationRequest object.
* created a #authenticate_reqest method that can be used when signature
verification is initialized w/ the request
* #authenticate_user_request works as before
Diffstat (limited to 'lib/mixlib/authentication/signatureverification.rb')
-rw-r--r-- | lib/mixlib/authentication/signatureverification.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/mixlib/authentication/signatureverification.rb b/lib/mixlib/authentication/signatureverification.rb index c6f68a3..0562e12 100644 --- a/lib/mixlib/authentication/signatureverification.rb +++ b/lib/mixlib/authentication/signatureverification.rb @@ -47,18 +47,25 @@ module Mixlib def_delegator :@auth_request, :content_hash - include Mixlib::Authentication::SignedHeaderAuth + def_delegator :@auth_request, :request - attr_reader :request + include Mixlib::Authentication::SignedHeaderAuth attr_reader :auth_request - def initialize + def initialize(request=nil) + @auth_request = HTTPAuthenticationRequest.new(request) if request + @valid_signature, @valid_timestamp, @valid_content_hash = false, false, false + @hashed_body = nil - @request, @auth_request = nil, nil end + + def authenticate_user_request(request, user_lookup, time_skew=(15*60)) + @auth_request = HTTPAuthenticationRequest.new(request) + authenticate_request(user_lookup, time_skew) + end # Takes the request, boils down the pieces we are interested in, # looks up the user, generates a signature, and compares to # the signature in the request @@ -69,15 +76,15 @@ module Mixlib # X-Ops-Timestamp: # X-Ops-Content-Hash: # X-Ops-Authorization-#{line_number} - def authenticate_user_request(request, user_lookup, time_skew=(15*60)) + def authenticate_request(user_secret, time_skew=(15*60)) Mixlib::Authentication::Log.debug "Initializing header auth : #{request.inspect}" @request = request - @user_secret = user_lookup + @user_secret = user_secret @allowed_time_skew = time_skew # in seconds begin - @auth_request = HTTPAuthenticationRequest.new(request) + @auth_request.validate_headers! #BUGBUG Not doing anything with the signing description yet [cb] parse_signing_description |