lib/rack/simple_auth/hmac.rb in rack-simple_auth-0.0.5 vs lib/rack/simple_auth/hmac.rb in rack-simple_auth-0.0.6
- old
+ new
@@ -30,22 +30,22 @@
# checks for valid HMAC Request
# @param [Rack::Request] request [current Request]
# @return [boolean] ValidationStatus [If authorized returns true, else false]
def valid?(request)
+ @hash_array = build_allowed_messages(request)
+
if request.env['HTTP_AUTHORIZATION'].nil?
log(request)
return false
end
auth_array = request.env['HTTP_AUTHORIZATION'].split(':')
message_hash = auth_array[0]
signature = auth_array[1]
- @hash_array = build_allowed_messages(request)
-
if signature == @signature && @hash_array.include?(message_hash)
true
else
log(request)
@@ -104,13 +104,15 @@
path = request.path
method = request.request_method
log = "#{Time.new} - #{method} #{path} - 400 Unauthorized - HTTP_AUTHORIZATION: #{request.env['HTTP_AUTHORIZATION']}\n"
log << "Auth Message Config: #{@config[request.request_method]}\n"
- log << "Allowed Encrypted Messages:\n"
- @hash_array.each do |hash|
- log << "#{hash}\n"
+ if @hash_array
+ log << "Allowed Encrypted Messages:\n"
+ @hash_array.each do |hash|
+ log << "#{hash}\n"
+ end
end
log << "Auth Signature: #{@signature}"
open("#{@logpath}/#{ENV['RACK_ENV']}_error.log", 'a') do |f|