mgomes / api_auth

HMAC authentication for Rails and HTTP Clients
MIT License
480 stars 147 forks source link

RestClient - MD5 not getting calculated #125

Closed t-anjan closed 6 years ago

t-anjan commented 8 years ago

https://github.com/mgomes/api_auth/blob/5a1bafe7581b29188cc3487325bcbbdd0237764d/lib/api_auth/request_drivers/rest_client.rb#L32

def populate_content_md5
   return unless [:post, :put].include?(@request.method)
   @request.headers['Content-MD5'] = calculated_md5
   save_headers
end

In the above line @request.method returns a string. But the code is checking for a symbol. Because of this, when signing the request, the MD5 does not get added to the header at all.

Is this a bug or am I missing something here?

I am using api-auth version 2.0.1 and rest-client version 2.0.0 .

kjg commented 8 years ago

After a quick look at the rest-client gem it looks like starting with 2.0 rest-client now normalizes RestClient::Request#method to a string

We should update api_auth to account for this. Nice find!