Author: jan Date: Sun Aug 23 15:04:02 2009 New Revision: 806984 URL: http://svn.apache.org/viewvc?rev=806984&view=rev Log: merge r806983 from trunk: fix HEAD requests for OAuth, patch by Jason Davies, closes COUCHDB-479
Modified: couchdb/branches/0.10.x/share/www/script/test/oauth.js couchdb/branches/0.10.x/src/couchdb/couch_httpd_oauth.erl Modified: couchdb/branches/0.10.x/share/www/script/test/oauth.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/share/www/script/test/oauth.js?rev=806984&r1=806983&r2=806984&view=diff ============================================================================== --- couchdb/branches/0.10.x/share/www/script/test/oauth.js (original) +++ couchdb/branches/0.10.x/share/www/script/test/oauth.js Sun Aug 23 15:04:02 2009 @@ -133,6 +133,10 @@ xhr = oauthRequest("http://" + host + "/_session?foo=bar", message, accessor); T(xhr.status == expectedCode); + // Test HEAD method + xhr = oauthRequest("http://" + host + "/_session?foo=bar", message, accessor, "HEAD"); + T(xhr.status == expectedCode); + // Replication var result = CouchDB.replicate(dbPair.source, dbPair.target); T(result.ok); Modified: couchdb/branches/0.10.x/src/couchdb/couch_httpd_oauth.erl URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/src/couchdb/couch_httpd_oauth.erl?rev=806984&r1=806983&r2=806984&view=diff ============================================================================== --- couchdb/branches/0.10.x/src/couchdb/couch_httpd_oauth.erl (original) +++ couchdb/branches/0.10.x/src/couchdb/couch_httpd_oauth.erl Sun Aug 23 15:04:02 2009 @@ -16,11 +16,11 @@ -export([oauth_authentication_handler/1, handle_oauth_req/1, consumer_lookup/2]). % OAuth auth handler using per-node user db -oauth_authentication_handler(#httpd{method=Method}=Req) -> +oauth_authentication_handler(#httpd{mochi_req=MochiReq}=Req) -> serve_oauth(Req, fun(URL, Params, Consumer, Signature) -> AccessToken = proplists:get_value("oauth_token", Params), TokenSecret = couch_config:get("oauth_token_secrets", AccessToken), - case oauth:verify(Signature, atom_to_list(Method), URL, Params, Consumer, TokenSecret) of + case oauth:verify(Signature, atom_to_list(MochiReq:get(method)), URL, Params, Consumer, TokenSecret) of true -> set_user_ctx(Req, AccessToken); false ->