Permalink
Browse files

Only send opaque auth attribute if the server sent it with the challenge

Apache's mod_digest will not accept a client response that includes opaque unless the server also includes opaque. By default, mod_digest does not send opaque which means ActiveResource doesn't work with mod_digest out of the box.

This change modifies auth_attributes_for to only include opaque if it was not blank.
  • Loading branch information...
gmoore committed Jul 13, 2013
1 parent 15089f9 commit 4f22f684f96db900cb0a88eb65ef78dc07c84421
Showing with 13 additions and 10 deletions.
  1. +13 −10 lib/active_resource/connection.rb
@@ -260,16 +260,19 @@ def extract_params_from_response
end
def auth_attributes_for(uri, request_digest, params)
- [
- %Q(username="#{@user}"),
- %Q(realm="#{params['realm']}"),
- %Q(qop="#{params['qop']}"),
- %Q(uri="#{uri.path}"),
- %Q(nonce="#{params['nonce']}"),
- %Q(nc="0"),
- %Q(cnonce="#{params['cnonce']}"),
- %Q(opaque="#{params['opaque']}"),
- %Q(response="#{request_digest}")].join(", ")
+ auth_attrs =
+ [
+ %Q(username="#{@user}"),
+ %Q(realm="#{params['realm']}"),
+ %Q(qop="#{params['qop']}"),
+ %Q(uri="#{uri.path}"),
+ %Q(nonce="#{params['nonce']}"),
+ %Q(nc="0"),
+ %Q(cnonce="#{params['cnonce']}"),
+ %Q(response="#{request_digest}")].join(", ")
+
+ auth_attrs << %Q(opaque="#{params['opaque']}") unless params['opaque'].blank?
+ auth_attrs
end
def http_format_header(http_method)

0 comments on commit 4f22f68

Please sign in to comment.