lib/shutl/resource/default_logger.rb in shutl_resource-1.3.4 vs lib/shutl/resource/default_logger.rb in shutl_resource-1.3.5
- old
+ new
@@ -37,17 +37,20 @@
def response_info(env, response_time)
" Response from %s; Status: %d; Time: %.1fms" % [ env[:url], env[:status], (response_time * 1_000.0) ]
end
def request_debug(env)
- request_headers = strip_auth env[:request_headers]
+ request_headers = obfuscate_auth env[:request_headers]
debug_message("Request", request_headers, env[:body])
end
- def strip_auth(headers)
+ def obfuscate_auth(headers)
headers.dup.tap do |h|
- h["Authorization"] = h["Authorization"][0..3] << "***" << h["Authorization"][-4..-1]
+ if auth = h["Authorization"]
+ #display first few and last few characters
+ h["Authorization"] = "#{auth[0..10]}****#{auth[-4..-1]}"
+ end
end
end
def response_debug(env)
debug_message("Response", env[:response_headers], env[:body])