summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2018-04-11 14:23:25 +0100
committerThom May <thom@chef.io>2018-04-11 14:23:25 +0100
commit23e5b6782725f646ad40bdc38b5ece50bf044534 (patch)
tree8f4f40385581eb01785daa178b21d89eac261785 /lib
parenta2fbf74d0b2123b9cc28e3baf7ca81b061036635 (diff)
downloadmixlib-authentication-23e5b6782725f646ad40bdc38b5ece50bf044534.tar.gz
Move mixlib-auth debugging to trace leveltm/logging
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/mixlib/authentication/http_authentication_request.rb2
-rw-r--r--lib/mixlib/authentication/null_logger.rb4
-rw-r--r--lib/mixlib/authentication/signatureverification.rb28
-rw-r--r--lib/mixlib/authentication/signedheaderauth.rb6
4 files changed, 20 insertions, 20 deletions
diff --git a/lib/mixlib/authentication/http_authentication_request.rb b/lib/mixlib/authentication/http_authentication_request.rb
index b573d2d..32b8e72 100644
--- a/lib/mixlib/authentication/http_authentication_request.rb
+++ b/lib/mixlib/authentication/http_authentication_request.rb
@@ -72,7 +72,7 @@ module Mixlib
unless @request_signature
@request_signature = headers.find_all { |h| h[0].to_s =~ /^x_ops_authorization_/ }
.sort { |x, y| x.to_s[/\d+/].to_i <=> y.to_s[/\d+/].to_i }.map { |i| i[1] }.join("\n")
- Mixlib::Authentication::Log.debug "Reconstituted (user-supplied) request signature: #{@request_signature}"
+ Mixlib::Authentication::Log.trace "Reconstituted (user-supplied) request signature: #{@request_signature}"
end
@request_signature
end
diff --git a/lib/mixlib/authentication/null_logger.rb b/lib/mixlib/authentication/null_logger.rb
index 2bc9e31..579b1e2 100644
--- a/lib/mixlib/authentication/null_logger.rb
+++ b/lib/mixlib/authentication/null_logger.rb
@@ -4,7 +4,7 @@ module Mixlib
attr_accessor :level
- %i{debug info warn error fatal}.each do |method_name|
+ %i{trace debug info warn error fatal}.each do |method_name|
class_eval(<<-METHOD_DEFN, __FILE__, __LINE__)
def #{method_name}(msg=nil, &block)
true
@@ -12,7 +12,7 @@ module Mixlib
METHOD_DEFN
end
- %i{debug? info? warn? error? fatal?}.each do |method_name|
+ %i{trace? debug? info? warn? error? fatal?}.each do |method_name|
class_eval(<<-METHOD_DEFN, __FILE__, __LINE__)
def #{method_name}
false
diff --git a/lib/mixlib/authentication/signatureverification.rb b/lib/mixlib/authentication/signatureverification.rb
index 898e05b..33094d2 100644
--- a/lib/mixlib/authentication/signatureverification.rb
+++ b/lib/mixlib/authentication/signatureverification.rb
@@ -76,7 +76,7 @@ module Mixlib
# X-Ops-Content-Hash:
# X-Ops-Authorization-#{line_number}
def authenticate_request(user_secret, time_skew = (15 * 60))
- Mixlib::Authentication.logger.debug "Initializing header auth : #{request.inspect}"
+ Mixlib::Authentication.logger.trace "Initializing header auth : #{request.inspect}"
@user_secret = user_secret
@allowed_time_skew = time_skew # in seconds
@@ -149,15 +149,15 @@ module Mixlib
(request_decrypted_block == candidate_block)
end
- # Keep the debug messages lined up so it's easy to scan them
- Mixlib::Authentication.logger.debug("Verifying request signature:")
- Mixlib::Authentication.logger.debug(" Expected Block is: '#{candidate_block}'")
- Mixlib::Authentication.logger.debug("Decrypted block is: '#{request_decrypted_block}'")
- Mixlib::Authentication.logger.debug("Signatures match? : '#{@valid_signature}'")
+ # Keep the trace messages lined up so it's easy to scan them
+ Mixlib::Authentication.logger.trace("Verifying request signature:")
+ Mixlib::Authentication.logger.trace(" Expected Block is: '#{candidate_block}'")
+ Mixlib::Authentication.logger.trace("Decrypted block is: '#{request_decrypted_block}'")
+ Mixlib::Authentication.logger.trace("Signatures match? : '#{@valid_signature}'")
@valid_signature
rescue => e
- Mixlib::Authentication.logger.debug("Failed to verify request signature: #{e.class.name}: #{e.message}")
+ Mixlib::Authentication.logger.trace("Failed to verify request signature: #{e.class.name}: #{e.message}")
@valid_signature = false
end
@@ -168,10 +168,10 @@ module Mixlib
def verify_content_hash
@valid_content_hash = (content_hash == hashed_body)
- # Keep the debug messages lined up so it's easy to scan them
- Mixlib::Authentication.logger.debug("Expected content hash is: '#{hashed_body}'")
- Mixlib::Authentication.logger.debug(" Request Content Hash is: '#{content_hash}'")
- Mixlib::Authentication.logger.debug(" Hashes match?: #{@valid_content_hash}")
+ # Keep the trace messages lined up so it's easy to scan them
+ Mixlib::Authentication.logger.trace("Expected content hash is: '#{hashed_body}'")
+ Mixlib::Authentication.logger.trace(" Request Content Hash is: '#{content_hash}'")
+ Mixlib::Authentication.logger.trace(" Hashes match?: #{@valid_content_hash}")
@valid_content_hash
end
@@ -211,11 +211,11 @@ module Mixlib
# Any file that's included in the request is hashed if it's there. Otherwise,
# we hash the body.
if file_param
- Mixlib::Authentication.logger.debug "Digesting file_param: '#{file_param.inspect}'"
+ Mixlib::Authentication.logger.trace "Digesting file_param: '#{file_param.inspect}'"
@hashed_body = digester.hash_file(file_param, digest)
else
body = request.raw_post
- Mixlib::Authentication.logger.debug "Digesting body: '#{body}'"
+ Mixlib::Authentication.logger.trace "Digesting body: '#{body}'"
@hashed_body = digester.hash_string(body, digest)
end
end
@@ -232,7 +232,7 @@ module Mixlib
def timestamp_within_bounds?(time1, time2)
time_diff = (time2 - time1).abs
is_allowed = (time_diff < @allowed_time_skew)
- Mixlib::Authentication.logger.debug "Request time difference: #{time_diff}, within #{@allowed_time_skew} seconds? : #{!!is_allowed}"
+ Mixlib::Authentication.logger.trace "Request time difference: #{time_diff}, within #{@allowed_time_skew} seconds? : #{!!is_allowed}"
is_allowed
end
end
diff --git a/lib/mixlib/authentication/signedheaderauth.rb b/lib/mixlib/authentication/signedheaderauth.rb
index e870135..6b9b850 100644
--- a/lib/mixlib/authentication/signedheaderauth.rb
+++ b/lib/mixlib/authentication/signedheaderauth.rb
@@ -115,7 +115,7 @@ module Mixlib
header_hash[key] = signature_lines[idx]
end
- Mixlib::Authentication.logger.debug "Header hash: #{header_hash.inspect}"
+ Mixlib::Authentication.logger.trace "Header hash: #{header_hash.inspect}"
header_hash
end
@@ -236,7 +236,7 @@ module Mixlib
memo[field_name.to_sym] = field_value.strip
memo
end
- Mixlib::Authentication.logger.debug "Parsed signing description: #{parts.inspect}"
+ Mixlib::Authentication.logger.trace "Parsed signing description: #{parts.inspect}"
parts
end
@@ -247,7 +247,7 @@ module Mixlib
# private
def do_sign(private_key, digest, sign_algorithm, sign_version)
string_to_sign = canonicalize_request(sign_algorithm, sign_version)
- Mixlib::Authentication.logger.debug "String to sign: '#{string_to_sign}'"
+ Mixlib::Authentication.logger.trace "String to sign: '#{string_to_sign}'"
case sign_version
when "1.3"
private_key.sign(digest.new, string_to_sign)