You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/12 07:22:19 UTC

[01/12] oauth commit: updated refs/heads/import-master to db23ab2

Updated Branches:
  refs/heads/import-master [created] db23ab232


Initial check-in of OAuth and cookie authentication.

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@800938 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/06abc695
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/06abc695
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/06abc695

Branch: refs/heads/import-master
Commit: 06abc6954e26b4517ed7ed34b7063f0d96cc0732
Parents: 
Author: Damien F. Katz <da...@apache.org>
Authored: Tue Aug 4 19:50:46 2009 +0000
Committer: Damien F. Katz <da...@apache.org>
Committed: Tue Aug 4 19:50:46 2009 +0000

----------------------------------------------------------------------
 Makefile.am         |  47 +++++++++++++++++++++
 oauth.app           |  20 +++++++++
 oauth.erl           | 107 +++++++++++++++++++++++++++++++++++++++++++++++
 oauth_hmac_sha1.erl |  11 +++++
 oauth_http.erl      |  22 ++++++++++
 oauth_plaintext.erl |  10 +++++
 oauth_rsa_sha1.erl  |  30 +++++++++++++
 oauth_unix.erl      |  16 +++++++
 oauth_uri.erl       |  88 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 351 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..e20bf2b
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,47 @@
+## Licensed under the Apache License, Version 2.0 (the "License"); you may not
+## use this file except in compliance with the License.  You may obtain a copy
+## of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+## License for the specific language governing permissions and limitations under
+## the License.
+
+oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
+
+oauth_file_collection = \
+    oauth.erl \
+    oauth_hmac_sha1.erl \
+    oauth_http.erl \
+    oauth_plaintext.erl \
+    oauth_rsa_sha1.erl \
+    oauth_unix.erl \
+    oauth_uri.erl
+
+oauthebin_static_file = oauth.app
+
+oauthebin_make_generated_file_list = \
+    oauth.beam \
+    oauth_hmac_sha1.beam \
+    oauth_http.beam \
+    oauth_plaintext.beam \
+    oauth_rsa_sha1.beam \
+    oauth_unix.beam \
+    oauth_uri.beam
+
+oauthebin_DATA = \
+    $(oauthebin_static_file) \
+    $(oauthebin_make_generated_file_list)
+
+EXTRA_DIST =  \
+    $(oauth_file_collection) \
+    $(oauthebin_static_file)
+
+CLEANFILES = \
+    $(oauthebin_make_generated_file_list)
+
+%.beam: %.erl
+	$(ERLC) $(ERLC_FLAGS) $<

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth.app
----------------------------------------------------------------------
diff --git a/oauth.app b/oauth.app
new file mode 100644
index 0000000..6357b9b
--- /dev/null
+++ b/oauth.app
@@ -0,0 +1,20 @@
+{application, oauth, [
+  {description, "Erlang OAuth implementation"},
+  {vsn, "dev"},
+  {modules, [
+    oauth,
+    oauth_hmac_sha1,
+    oauth_http,
+    oauth_plaintext,
+    oauth_rsa_sha1,
+    oauth_unix,
+    oauth_uri
+  ]},
+  {registered, []},
+  {applications, [
+    kernel,
+    stdlib,
+    crypto,
+    inets
+  ]}
+]}.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth.erl
----------------------------------------------------------------------
diff --git a/oauth.erl b/oauth.erl
new file mode 100644
index 0000000..866655c
--- /dev/null
+++ b/oauth.erl
@@ -0,0 +1,107 @@
+-module(oauth).
+
+-export(
+  [ get/5
+  , header/1
+  , post/5
+  , signature/5
+  , signature_base_string/3
+  , signed_params/6
+  , token/1
+  , token_secret/1
+  , uri/2
+  , verify/6
+  ]).
+
+
+get(URL, ExtraParams, Consumer, Token, TokenSecret) ->
+  SignedParams = signed_params("GET", URL, ExtraParams, Consumer, Token, TokenSecret),
+  oauth_http:get(uri(URL, SignedParams)).
+
+post(URL, ExtraParams, Consumer, Token, TokenSecret) ->
+  SignedParams = signed_params("POST", URL, ExtraParams, Consumer, Token, TokenSecret),
+  oauth_http:post(URL, oauth_uri:params_to_string(SignedParams)).
+
+uri(Base, []) ->
+  Base;
+uri(Base, Params) ->
+  lists:concat([Base, "?", oauth_uri:params_to_string(Params)]).
+
+header(Params) ->
+  {"Authorization", "OAuth " ++ oauth_uri:params_to_header_string(Params)}.
+
+token(Params) ->
+  proplists:get_value("oauth_token", Params).
+
+token_secret(Params) ->
+  proplists:get_value("oauth_token_secret", Params).
+
+verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret) ->
+  case signature_method(Consumer) of
+    plaintext ->
+      oauth_plaintext:verify(Signature, consumer_secret(Consumer), TokenSecret);
+    hmac_sha1 ->
+      BaseString = signature_base_string(HttpMethod, URL, Params),
+      oauth_hmac_sha1:verify(Signature, BaseString, consumer_secret(Consumer), TokenSecret);
+    rsa_sha1 ->
+      BaseString = signature_base_string(HttpMethod, URL, Params),
+      oauth_rsa_sha1:verify(Signature, BaseString, consumer_secret(Consumer))
+  end.
+
+signed_params(HttpMethod, URL, ExtraParams, Consumer, Token, TokenSecret) ->
+  Params = token_param(Token, params(Consumer, ExtraParams)),
+  [{"oauth_signature", signature(HttpMethod, URL, Params, Consumer, TokenSecret)}|Params].
+
+signature(HttpMethod, URL, Params, Consumer, TokenSecret) ->
+  case signature_method(Consumer) of
+    plaintext ->
+      oauth_plaintext:signature(consumer_secret(Consumer), TokenSecret);
+    hmac_sha1 ->
+      BaseString = signature_base_string(HttpMethod, URL, Params),
+      oauth_hmac_sha1:signature(BaseString, consumer_secret(Consumer), TokenSecret);
+    rsa_sha1 ->
+      BaseString = signature_base_string(HttpMethod, URL, Params),
+      oauth_rsa_sha1:signature(BaseString, consumer_secret(Consumer))
+  end.
+
+signature_base_string(HttpMethod, URL, Params) ->
+  NormalizedURL = oauth_uri:normalize(URL),
+  NormalizedParams = oauth_uri:params_to_string(lists:sort(Params)),
+  oauth_uri:calate("&", [HttpMethod, NormalizedURL, NormalizedParams]).
+
+token_param("", Params) ->
+  Params;
+token_param(Token, Params) ->
+  [{"oauth_token", Token}|Params].
+
+params(Consumer, Params) ->
+  Nonce = base64:encode_to_string(crypto:rand_bytes(32)), % cf. ruby-oauth
+  params(Consumer, oauth_unix:timestamp(), Nonce, Params).
+
+params(Consumer, Timestamp, Nonce, Params) ->
+  [ {"oauth_version", "1.0"}
+  , {"oauth_nonce", Nonce}
+  , {"oauth_timestamp", integer_to_list(Timestamp)}
+  , {"oauth_signature_method", signature_method_string(Consumer)}
+  , {"oauth_consumer_key", consumer_key(Consumer)}
+  | Params
+  ].
+
+signature_method_string(Consumer) ->
+  case signature_method(Consumer) of
+    plaintext ->
+      "PLAINTEXT";
+    hmac_sha1 ->
+      "HMAC-SHA1";
+    rsa_sha1 ->
+      "RSA-SHA1"
+  end.
+
+signature_method(_Consumer={_, _, Method}) ->
+  Method.
+
+consumer_secret(_Consumer={_, Secret, _}) ->
+  Secret.
+
+consumer_key(_Consumer={Key, _, _}) ->
+  Key.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth_hmac_sha1.erl
----------------------------------------------------------------------
diff --git a/oauth_hmac_sha1.erl b/oauth_hmac_sha1.erl
new file mode 100644
index 0000000..69064ed
--- /dev/null
+++ b/oauth_hmac_sha1.erl
@@ -0,0 +1,11 @@
+-module(oauth_hmac_sha1).
+
+-export([signature/3, verify/4]).
+
+
+signature(BaseString, CS, TS) ->
+  Key = oauth_uri:calate("&", [CS, TS]),
+  base64:encode_to_string(crypto:sha_mac(Key, BaseString)).
+
+verify(Signature, BaseString, CS, TS) ->
+  Signature =:= signature(BaseString, CS, TS).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth_http.erl
----------------------------------------------------------------------
diff --git a/oauth_http.erl b/oauth_http.erl
new file mode 100644
index 0000000..bf5a4ba
--- /dev/null
+++ b/oauth_http.erl
@@ -0,0 +1,22 @@
+-module(oauth_http).
+
+-export([get/1, post/2, response_params/1, response_body/1, response_code/1]).
+
+
+get(URL) ->
+  request(get, {URL, []}).
+
+post(URL, Data) ->
+  request(post, {URL, [], "application/x-www-form-urlencoded", Data}).
+
+request(Method, Request) ->
+  http:request(Method, Request, [{autoredirect, false}], []).
+
+response_params(Response) ->
+  oauth_uri:params_from_string(response_body(Response)).
+
+response_body({{_, _, _}, _, Body}) ->
+  Body.
+
+response_code({{_, Code, _}, _, _}) ->
+  Code.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth_plaintext.erl
----------------------------------------------------------------------
diff --git a/oauth_plaintext.erl b/oauth_plaintext.erl
new file mode 100644
index 0000000..d8085e0
--- /dev/null
+++ b/oauth_plaintext.erl
@@ -0,0 +1,10 @@
+-module(oauth_plaintext).
+
+-export([signature/2, verify/3]).
+
+
+signature(CS, TS) ->
+  oauth_uri:calate("&", [CS, TS]).
+
+verify(Signature, CS, TS) ->
+  Signature =:= signature(CS, TS).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth_rsa_sha1.erl
----------------------------------------------------------------------
diff --git a/oauth_rsa_sha1.erl b/oauth_rsa_sha1.erl
new file mode 100644
index 0000000..6f4828e
--- /dev/null
+++ b/oauth_rsa_sha1.erl
@@ -0,0 +1,30 @@
+-module(oauth_rsa_sha1).
+
+-export([signature/2, verify/3]).
+
+-include_lib("public_key/include/public_key.hrl").
+
+
+signature(BaseString, PrivateKeyPath) ->
+  {ok, [Info]} = public_key:pem_to_der(PrivateKeyPath),
+  {ok, PrivateKey} = public_key:decode_private_key(Info),
+  base64:encode_to_string(public_key:sign(list_to_binary(BaseString), PrivateKey)).
+
+verify(Signature, BaseString, PublicKey) ->
+  public_key:verify_signature(to_binary(BaseString), sha, base64:decode(Signature), public_key(PublicKey)).
+
+to_binary(Term) when is_list(Term) ->
+  list_to_binary(Term);
+to_binary(Term) when is_binary(Term) ->
+  Term.
+
+public_key(Path) when is_list(Path) ->
+  {ok, [{cert, DerCert, not_encrypted}]} = public_key:pem_to_der(Path),
+  {ok, Cert} = public_key:pkix_decode_cert(DerCert, otp),
+  public_key(Cert);
+public_key(#'OTPCertificate'{tbsCertificate=Cert}) ->
+  public_key(Cert);
+public_key(#'OTPTBSCertificate'{subjectPublicKeyInfo=Info}) ->
+  public_key(Info);
+public_key(#'OTPSubjectPublicKeyInfo'{subjectPublicKey=Key}) ->
+  Key.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth_unix.erl
----------------------------------------------------------------------
diff --git a/oauth_unix.erl b/oauth_unix.erl
new file mode 100644
index 0000000..73ca314
--- /dev/null
+++ b/oauth_unix.erl
@@ -0,0 +1,16 @@
+-module(oauth_unix).
+
+-export([timestamp/0]).
+
+
+timestamp() ->
+  timestamp(calendar:universal_time()).
+
+timestamp(DateTime) ->
+  seconds(DateTime) - epoch().
+
+epoch() ->
+  seconds({{1970,1,1},{00,00,00}}).
+
+seconds(DateTime) ->
+  calendar:datetime_to_gregorian_seconds(DateTime).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/06abc695/oauth_uri.erl
----------------------------------------------------------------------
diff --git a/oauth_uri.erl b/oauth_uri.erl
new file mode 100644
index 0000000..fb27ae7
--- /dev/null
+++ b/oauth_uri.erl
@@ -0,0 +1,88 @@
+-module(oauth_uri).
+
+-export([normalize/1, calate/2, encode/1]).
+-export([params_from_string/1, params_to_string/1,
+  params_from_header_string/1, params_to_header_string/1]).
+
+-import(lists, [concat/1]).
+
+-define(is_uppercase_alpha(C), C >= $A, C =< $Z).
+-define(is_lowercase_alpha(C), C >= $a, C =< $z).
+-define(is_alpha(C), ?is_uppercase_alpha(C); ?is_lowercase_alpha(C)).
+-define(is_digit(C), C >= $0, C =< $9).
+-define(is_alphanumeric(C), ?is_alpha(C); ?is_digit(C)).
+-define(is_unreserved(C), ?is_alphanumeric(C); C =:= $-; C =:= $_; C =:= $.; C =:= $~).
+-define(is_hex(C), ?is_digit(C); C >= $A, C =< $F).
+
+
+normalize(URI) ->
+  case http_uri:parse(URI) of
+    {Scheme, UserInfo, Host, Port, Path, _Query} ->
+      normalize(Scheme, UserInfo, string:to_lower(Host), Port, [Path]);
+    Else ->
+      Else
+  end.
+
+normalize(http, UserInfo, Host, 80, Acc) ->
+  normalize(http, UserInfo, [Host|Acc]);
+normalize(https, UserInfo, Host, 443, Acc) ->
+  normalize(https, UserInfo, [Host|Acc]);
+normalize(Scheme, UserInfo, Host, Port, Acc) ->
+  normalize(Scheme, UserInfo, [Host, ":", Port|Acc]).
+
+normalize(Scheme, [], Acc) ->
+  concat([Scheme, "://"|Acc]);
+normalize(Scheme, UserInfo, Acc) ->
+  concat([Scheme, "://", UserInfo, "@"|Acc]).
+
+params_to_header_string(Params) ->
+  intercalate(", ", [concat([encode(K), "=\"", encode(V), "\""]) || {K, V} <- Params]).
+
+params_from_header_string(String) ->
+  [param_from_header_string(Param) || Param <- re:split(String, ",\\s*", [{return, list}]), Param =/= ""].
+
+param_from_header_string(Param) ->
+  [Key, QuotedValue] = string:tokens(Param, "="),
+  Value = string:substr(QuotedValue, 2, length(QuotedValue) - 2),
+  {decode(Key), decode(Value)}.
+
+params_from_string(Params) ->
+  [param_from_string(Param) || Param <- string:tokens(Params, "&")].
+
+param_from_string(Param) ->
+  list_to_tuple([decode(Value) || Value <- string:tokens(Param, "=")]).
+
+params_to_string(Params) ->
+  intercalate("&", [calate("=", [K, V]) || {K, V} <- Params]).
+
+calate(Sep, Xs) ->
+  intercalate(Sep, [encode(X) || X <- Xs]).
+
+intercalate(Sep, Xs) ->
+  concat(intersperse(Sep, Xs)).
+
+intersperse(_, []) -> [];
+intersperse(_, [X]) -> [X];
+intersperse(Sep, [X|Xs]) ->
+  [X, Sep|intersperse(Sep, Xs)].
+
+decode(Chars) ->
+  decode(Chars, []).
+
+decode([], Decoded) ->
+  lists:reverse(Decoded);
+decode([$%,A,B|Etc], Decoded) when ?is_hex(A), ?is_hex(B) ->
+  decode(Etc, [erlang:list_to_integer([A,B], 16)|Decoded]);
+decode([C|Etc], Decoded) when ?is_unreserved(C) ->
+  decode(Etc, [C|Decoded]).
+
+encode(Chars) ->
+  encode(Chars, []).
+
+encode([], Encoded) ->
+  lists:flatten(lists:reverse(Encoded));
+encode([C|Etc], Encoded) when ?is_unreserved(C) ->
+  encode(Etc, [C|Encoded]);
+encode([C|Etc], Encoded) ->
+  Value = io_lib:format("%~2.1.0s", [erlang:integer_to_list(C, 16)]),
+  encode(Etc, [Value|Encoded]).


[07/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
Add utility for verifying hashes.


git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@898477 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/a24be94a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/a24be94a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/a24be94a

Branch: refs/heads/import-master
Commit: a24be94aa71172a0bd4af78514a2e201c929675d
Parents: 66f4148
Author: Jason David Davies <ja...@apache.org>
Authored: Tue Jan 12 19:29:23 2010 +0000
Committer: Jason David Davies <ja...@apache.org>
Committed: Tue Jan 12 19:29:23 2010 +0000

----------------------------------------------------------------------
 oauth_hmac_sha1.erl | 2 +-
 oauth_plaintext.erl | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/a24be94a/oauth_hmac_sha1.erl
----------------------------------------------------------------------
diff --git a/oauth_hmac_sha1.erl b/oauth_hmac_sha1.erl
index 69064ed..79d59f3 100644
--- a/oauth_hmac_sha1.erl
+++ b/oauth_hmac_sha1.erl
@@ -8,4 +8,4 @@ signature(BaseString, CS, TS) ->
   base64:encode_to_string(crypto:sha_mac(Key, BaseString)).
 
 verify(Signature, BaseString, CS, TS) ->
-  Signature =:= signature(BaseString, CS, TS).
+  couch_util:verify(signature(BaseString, CS, TS), Signature).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/a24be94a/oauth_plaintext.erl
----------------------------------------------------------------------
diff --git a/oauth_plaintext.erl b/oauth_plaintext.erl
index d8085e0..41a1e9b 100644
--- a/oauth_plaintext.erl
+++ b/oauth_plaintext.erl
@@ -7,4 +7,4 @@ signature(CS, TS) ->
   oauth_uri:calate("&", [CS, TS]).
 
 verify(Signature, CS, TS) ->
-  Signature =:= signature(CS, TS).
+  couch_util:verify(signature(CS, TS), Signature).


[11/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
add support of erlang R15B in oauth.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/b6f836dd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/b6f836dd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/b6f836dd

Branch: refs/heads/import-master
Commit: b6f836dd6cabd746f532df81d8389506a1267284
Parents: 07b034b
Author: benoitc <be...@apache.org>
Authored: Mon Jan 2 17:39:01 2012 +0100
Committer: benoitc <be...@apache.org>
Committed: Mon Jan 2 17:39:01 2012 +0100

----------------------------------------------------------------------
 oauth_uri.erl | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/b6f836dd/oauth_uri.erl
----------------------------------------------------------------------
diff --git a/oauth_uri.erl b/oauth_uri.erl
index 5023f98..aebf093 100644
--- a/oauth_uri.erl
+++ b/oauth_uri.erl
@@ -9,6 +9,8 @@
 
 normalize(URI) ->
   case http_uri:parse(URI) of
+    {ok, {Scheme, UserInfo, Host, Port, Path, _Query}} -> % R15B
+        normalize(Scheme, UserInfo, string:to_lower(Host), Port, [Path]);
     {Scheme, UserInfo, Host, Port, Path, _Query} ->
       normalize(Scheme, UserInfo, string:to_lower(Host), Port, [Path]);
     Else ->


[09/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
Update erlang_oauth to the latest version.

Fixes deprecation warnings for R15 and a few minor things:

 https://github.com/tim/erlang-oauth/commits/master

(This includes one small patch that I'm sending upstream now)

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1039345 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/d8594f74
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/d8594f74
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/d8594f74

Branch: refs/heads/import-master
Commit: d8594f74e5acf7690c368fb70d5c7a47074d8c56
Parents: fb60e65
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Nov 26 13:29:25 2010 +0000
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Fri Nov 26 13:29:25 2010 +0000

----------------------------------------------------------------------
 oauth.app.in        |  2 +-
 oauth_hmac_sha1.erl |  2 +-
 oauth_http.erl      |  2 +-
 oauth_plaintext.erl |  2 +-
 oauth_uri.erl       | 66 ++++++++++++++++++++++++++++--------------------
 5 files changed, 42 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/d8594f74/oauth.app.in
----------------------------------------------------------------------
diff --git a/oauth.app.in b/oauth.app.in
index 6357b9b..a8ec17c 100644
--- a/oauth.app.in
+++ b/oauth.app.in
@@ -1,6 +1,6 @@
 {application, oauth, [
   {description, "Erlang OAuth implementation"},
-  {vsn, "dev"},
+  {vsn, "7d85d3ef"},
   {modules, [
     oauth,
     oauth_hmac_sha1,

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/d8594f74/oauth_hmac_sha1.erl
----------------------------------------------------------------------
diff --git a/oauth_hmac_sha1.erl b/oauth_hmac_sha1.erl
index 79d59f3..69064ed 100644
--- a/oauth_hmac_sha1.erl
+++ b/oauth_hmac_sha1.erl
@@ -8,4 +8,4 @@ signature(BaseString, CS, TS) ->
   base64:encode_to_string(crypto:sha_mac(Key, BaseString)).
 
 verify(Signature, BaseString, CS, TS) ->
-  couch_util:verify(signature(BaseString, CS, TS), Signature).
+  Signature =:= signature(BaseString, CS, TS).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/d8594f74/oauth_http.erl
----------------------------------------------------------------------
diff --git a/oauth_http.erl b/oauth_http.erl
index bf5a4ba..92c806c 100644
--- a/oauth_http.erl
+++ b/oauth_http.erl
@@ -10,7 +10,7 @@ post(URL, Data) ->
   request(post, {URL, [], "application/x-www-form-urlencoded", Data}).
 
 request(Method, Request) ->
-  http:request(Method, Request, [{autoredirect, false}], []).
+  httpc:request(Method, Request, [{autoredirect, false}], []).
 
 response_params(Response) ->
   oauth_uri:params_from_string(response_body(Response)).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/d8594f74/oauth_plaintext.erl
----------------------------------------------------------------------
diff --git a/oauth_plaintext.erl b/oauth_plaintext.erl
index 41a1e9b..d8085e0 100644
--- a/oauth_plaintext.erl
+++ b/oauth_plaintext.erl
@@ -7,4 +7,4 @@ signature(CS, TS) ->
   oauth_uri:calate("&", [CS, TS]).
 
 verify(Signature, CS, TS) ->
-  couch_util:verify(signature(CS, TS), Signature).
+  Signature =:= signature(CS, TS).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/d8594f74/oauth_uri.erl
----------------------------------------------------------------------
diff --git a/oauth_uri.erl b/oauth_uri.erl
index fb27ae7..5023f98 100644
--- a/oauth_uri.erl
+++ b/oauth_uri.erl
@@ -6,14 +6,6 @@
 
 -import(lists, [concat/1]).
 
--define(is_uppercase_alpha(C), C >= $A, C =< $Z).
--define(is_lowercase_alpha(C), C >= $a, C =< $z).
--define(is_alpha(C), ?is_uppercase_alpha(C); ?is_lowercase_alpha(C)).
--define(is_digit(C), C >= $0, C =< $9).
--define(is_alphanumeric(C), ?is_alpha(C); ?is_digit(C)).
--define(is_unreserved(C), ?is_alphanumeric(C); C =:= $-; C =:= $_; C =:= $.; C =:= $~).
--define(is_hex(C), ?is_digit(C); C >= $A, C =< $F).
-
 
 normalize(URI) ->
   case http_uri:parse(URI) of
@@ -66,23 +58,41 @@ intersperse(_, [X]) -> [X];
 intersperse(Sep, [X|Xs]) ->
   [X, Sep|intersperse(Sep, Xs)].
 
-decode(Chars) ->
-  decode(Chars, []).
-
-decode([], Decoded) ->
-  lists:reverse(Decoded);
-decode([$%,A,B|Etc], Decoded) when ?is_hex(A), ?is_hex(B) ->
-  decode(Etc, [erlang:list_to_integer([A,B], 16)|Decoded]);
-decode([C|Etc], Decoded) when ?is_unreserved(C) ->
-  decode(Etc, [C|Decoded]).
-
-encode(Chars) ->
-  encode(Chars, []).
-
-encode([], Encoded) ->
-  lists:flatten(lists:reverse(Encoded));
-encode([C|Etc], Encoded) when ?is_unreserved(C) ->
-  encode(Etc, [C|Encoded]);
-encode([C|Etc], Encoded) ->
-  Value = io_lib:format("%~2.1.0s", [erlang:integer_to_list(C, 16)]),
-  encode(Etc, [Value|Encoded]).
+-define(is_alphanum(C), C >= $A, C =< $Z; C >= $a, C =< $z; C >= $0, C =< $9).
+
+encode(Term) when is_integer(Term) ->
+  integer_to_list(Term);
+encode(Term) when is_atom(Term) ->
+  encode(atom_to_list(Term));
+encode(Term) when is_list(Term) ->
+  encode(lists:reverse(Term, []), []).
+
+encode([X | T], Acc) when ?is_alphanum(X); X =:= $-; X =:= $_; X =:= $.; X =:= $~ ->
+  encode(T, [X | Acc]);
+encode([X | T], Acc) ->
+  NewAcc = [$%, dec2hex(X bsr 4), dec2hex(X band 16#0f) | Acc],
+  encode(T, NewAcc);
+encode([], Acc) ->
+  Acc.
+
+decode(Str) when is_list(Str) ->
+  decode(Str, []).
+
+decode([$%, A, B | T], Acc) ->
+  decode(T, [(hex2dec(A) bsl 4) + hex2dec(B) | Acc]);
+decode([X | T], Acc) ->
+  decode(T, [X | Acc]);
+decode([], Acc) ->
+  lists:reverse(Acc, []).
+
+-compile({inline, [{dec2hex, 1}, {hex2dec, 1}]}).
+
+dec2hex(N) when N >= 10 andalso N =< 15 ->
+  N + $A - 10;
+dec2hex(N) when N >= 0 andalso N =< 9 ->
+  N + $0.
+
+hex2dec(C) when C >= $A andalso C =< $F ->
+  C - $A + 10;
+hex2dec(C) when C >= $0 andalso C =< $9 ->
+  C - $0.


[02/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
The RSA SHA1 Oauth module was breaking trunk for older versions of the Erlang
VM. Since we don't actually use it, I'm removing it from the build until
we add a ./conifgure option or we update our Erlang version requirement.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@801456 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/95c501f7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/95c501f7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/95c501f7

Branch: refs/heads/import-master
Commit: 95c501f7abb2dd4b6e8e75cc67aa6ad27a8c7fc7
Parents: 06abc69
Author: Paul Joseph Davis <da...@apache.org>
Authored: Wed Aug 5 23:08:25 2009 +0000
Committer: Paul Joseph Davis <da...@apache.org>
Committed: Wed Aug 5 23:08:25 2009 +0000

----------------------------------------------------------------------
 Makefile.am | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/95c501f7/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index e20bf2b..c87d7f6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,12 +12,14 @@
 
 oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
 
+# Removed oauth_rsa_sha1.erl until we require R12B5 or
+# we add a ./configure option to enable it.
+
 oauth_file_collection = \
     oauth.erl \
     oauth_hmac_sha1.erl \
     oauth_http.erl \
     oauth_plaintext.erl \
-    oauth_rsa_sha1.erl \
     oauth_unix.erl \
     oauth_uri.erl
 
@@ -28,7 +30,6 @@ oauthebin_make_generated_file_list = \
     oauth_hmac_sha1.beam \
     oauth_http.beam \
     oauth_plaintext.beam \
-    oauth_rsa_sha1.beam \
     oauth_unix.beam \
     oauth_uri.beam
 


[06/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
Fixes 'make distcheck' to run the test suite.

Quite a few changes to the build system to handle VPATH builds appropriately as well as make the test suite know about them.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@833951 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/66f41489
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/66f41489
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/66f41489

Branch: refs/heads/import-master
Commit: 66f41489a155b6382f0a30091210c6e1eedb7522
Parents: 7cc148b
Author: Paul Joseph Davis <da...@apache.org>
Authored: Mon Nov 9 00:39:16 2009 +0000
Committer: Paul Joseph Davis <da...@apache.org>
Committed: Mon Nov 9 00:39:16 2009 +0000

----------------------------------------------------------------------
 Makefile.am  | 15 ++++++++-------
 oauth.app    | 20 --------------------
 oauth.app.in | 20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/66f41489/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index c87d7f6..1d12339 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
 # we add a ./configure option to enable it.
 
 oauth_file_collection = \
+	oauth.app.in \
     oauth.erl \
     oauth_hmac_sha1.erl \
     oauth_http.erl \
@@ -23,9 +24,8 @@ oauth_file_collection = \
     oauth_unix.erl \
     oauth_uri.erl
 
-oauthebin_static_file = oauth.app
-
 oauthebin_make_generated_file_list = \
+	oauth.app \
     oauth.beam \
     oauth_hmac_sha1.beam \
     oauth_http.beam \
@@ -34,15 +34,16 @@ oauthebin_make_generated_file_list = \
     oauth_uri.beam
 
 oauthebin_DATA = \
-    $(oauthebin_static_file) \
-    $(oauthebin_make_generated_file_list)
+	$(oauthebin_make_generated_file_list)
 
-EXTRA_DIST =  \
-    $(oauth_file_collection) \
-    $(oauthebin_static_file)
+EXTRA_DIST = \
+	$(oauth_file_collection)
 
 CLEANFILES = \
     $(oauthebin_make_generated_file_list)
 
+%.app: %.app.in
+	cp $< $@
+
 %.beam: %.erl
 	$(ERLC) $(ERLC_FLAGS) $<

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/66f41489/oauth.app
----------------------------------------------------------------------
diff --git a/oauth.app b/oauth.app
deleted file mode 100644
index 6357b9b..0000000
--- a/oauth.app
+++ /dev/null
@@ -1,20 +0,0 @@
-{application, oauth, [
-  {description, "Erlang OAuth implementation"},
-  {vsn, "dev"},
-  {modules, [
-    oauth,
-    oauth_hmac_sha1,
-    oauth_http,
-    oauth_plaintext,
-    oauth_rsa_sha1,
-    oauth_unix,
-    oauth_uri
-  ]},
-  {registered, []},
-  {applications, [
-    kernel,
-    stdlib,
-    crypto,
-    inets
-  ]}
-]}.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/66f41489/oauth.app.in
----------------------------------------------------------------------
diff --git a/oauth.app.in b/oauth.app.in
new file mode 100644
index 0000000..6357b9b
--- /dev/null
+++ b/oauth.app.in
@@ -0,0 +1,20 @@
+{application, oauth, [
+  {description, "Erlang OAuth implementation"},
+  {vsn, "dev"},
+  {modules, [
+    oauth,
+    oauth_hmac_sha1,
+    oauth_http,
+    oauth_plaintext,
+    oauth_rsa_sha1,
+    oauth_unix,
+    oauth_uri
+  ]},
+  {registered, []},
+  {applications, [
+    kernel,
+    stdlib,
+    crypto,
+    inets
+  ]}
+]}.


[12/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
update erlang-oauth to 1.3.0


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/db23ab23
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/db23ab23
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/db23ab23

Branch: refs/heads/import-master
Commit: db23ab232f07f9b80b6315f730bf71913b9db9ee
Parents: b6f836d
Author: Jan Lehnardt <ja...@apache.org>
Authored: Mon Nov 12 21:11:39 2012 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sat Jan 12 19:16:41 2013 +0100

----------------------------------------------------------------------
 Makefile.am         |  15 +--
 oauth.erl           | 328 ++++++++++++++++++++++++++++++++++++++---------
 oauth_hmac_sha1.erl |  11 --
 oauth_http.erl      |  22 ----
 oauth_plaintext.erl |  10 --
 oauth_rsa_sha1.erl  |  30 -----
 oauth_unix.erl      |  16 ---
 oauth_uri.erl       | 100 ---------------
 8 files changed, 270 insertions(+), 262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 48b7648..a334677 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,25 +14,14 @@ oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
 
 oauth_file_collection = \
 	oauth.app.in \
-    oauth.erl \
-    oauth_hmac_sha1.erl \
-    oauth_http.erl \
-    oauth_plaintext.erl \
-    oauth_rsa_sha1.erl \
-    oauth_unix.erl \
-    oauth_uri.erl
+    oauth.erl
 
 # Removed oauth_rsa_sha1.beam until we require R12B5 or
 # we add a ./configure option to enable it.
 
 oauthebin_make_generated_file_list = \
 	oauth.app \
-    oauth.beam \
-    oauth_hmac_sha1.beam \
-    oauth_http.beam \
-    oauth_plaintext.beam \
-    oauth_unix.beam \
-    oauth_uri.beam
+    oauth.beam
 
 oauthebin_DATA = \
 	$(oauthebin_make_generated_file_list)

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/oauth.erl
----------------------------------------------------------------------
diff --git a/oauth.erl b/oauth.erl
index 866655c..e75d5fd 100644
--- a/oauth.erl
+++ b/oauth.erl
@@ -1,34 +1,54 @@
 -module(oauth).
 
--export(
-  [ get/5
-  , header/1
-  , post/5
-  , signature/5
-  , signature_base_string/3
-  , signed_params/6
-  , token/1
-  , token_secret/1
-  , uri/2
-  , verify/6
-  ]).
+-export([get/3, get/5, get/6, post/3, post/5, post/6, put/6, put/7, uri/2, header/1,
+  sign/6, params_decode/1, token/1, token_secret/1, verify/6]).
 
+-export([plaintext_signature/2, hmac_sha1_signature/5,
+  hmac_sha1_signature/3, rsa_sha1_signature/4, rsa_sha1_signature/2,
+  signature_base_string/3, params_encode/1]).
+
+-export([plaintext_verify/3, hmac_sha1_verify/6, hmac_sha1_verify/4,
+  rsa_sha1_verify/5, rsa_sha1_verify/3]).
+
+-export([header_params_encode/1, header_params_decode/1,
+  uri_params_encode/1, uri_params_decode/1]).
+
+-include_lib("public_key/include/public_key.hrl").
+
+get(URL, ExtraParams, Consumer) ->
+  get(URL, ExtraParams, Consumer, "", "").
 
 get(URL, ExtraParams, Consumer, Token, TokenSecret) ->
-  SignedParams = signed_params("GET", URL, ExtraParams, Consumer, Token, TokenSecret),
-  oauth_http:get(uri(URL, SignedParams)).
+  get(URL, ExtraParams, Consumer, Token, TokenSecret, []).
+
+get(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
+  SignedParams = sign("GET", URL, ExtraParams, Consumer, Token, TokenSecret),
+  http_request(get, {uri(URL, SignedParams), []}, HttpcOptions).
+
+post(URL, ExtraParams, Consumer) ->
+  post(URL, ExtraParams, Consumer, "", "").
 
 post(URL, ExtraParams, Consumer, Token, TokenSecret) ->
-  SignedParams = signed_params("POST", URL, ExtraParams, Consumer, Token, TokenSecret),
-  oauth_http:post(URL, oauth_uri:params_to_string(SignedParams)).
+  post(URL, ExtraParams, Consumer, Token, TokenSecret, []).
+
+post(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
+  SignedParams = sign("POST", URL, ExtraParams, Consumer, Token, TokenSecret),
+  http_request(post, {URL, [], "application/x-www-form-urlencoded", uri_params_encode(SignedParams)}, HttpcOptions).
+
+put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret) ->
+  put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret, []).
+
+put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret, HttpcOptions) ->
+  SignedParams = sign("PUT", URL, ExtraParams, Consumer, Token, TokenSecret),
+  http_request(put, {uri(URL, SignedParams), [], ContentType, Body}, HttpcOptions).
 
 uri(Base, []) ->
   Base;
 uri(Base, Params) ->
-  lists:concat([Base, "?", oauth_uri:params_to_string(Params)]).
+  lists:concat([Base, "?", uri_params_encode(Params)]).
 
 header(Params) ->
-  {"Authorization", "OAuth " ++ oauth_uri:params_to_header_string(Params)}.
+  {"Authorization", "OAuth " ++ header_params_encode(Params)}.
 
 token(Params) ->
   proplists:get_value("oauth_token", Params).
@@ -36,49 +56,28 @@ token(Params) ->
 token_secret(Params) ->
   proplists:get_value("oauth_token_secret", Params).
 
-verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret) ->
-  case signature_method(Consumer) of
-    plaintext ->
-      oauth_plaintext:verify(Signature, consumer_secret(Consumer), TokenSecret);
-    hmac_sha1 ->
-      BaseString = signature_base_string(HttpMethod, URL, Params),
-      oauth_hmac_sha1:verify(Signature, BaseString, consumer_secret(Consumer), TokenSecret);
-    rsa_sha1 ->
-      BaseString = signature_base_string(HttpMethod, URL, Params),
-      oauth_rsa_sha1:verify(Signature, BaseString, consumer_secret(Consumer))
-  end.
+consumer_key(_Consumer={Key, _, _}) ->
+  Key.
 
-signed_params(HttpMethod, URL, ExtraParams, Consumer, Token, TokenSecret) ->
-  Params = token_param(Token, params(Consumer, ExtraParams)),
-  [{"oauth_signature", signature(HttpMethod, URL, Params, Consumer, TokenSecret)}|Params].
+consumer_secret(_Consumer={_, Secret, _}) ->
+  Secret.
 
-signature(HttpMethod, URL, Params, Consumer, TokenSecret) ->
-  case signature_method(Consumer) of
-    plaintext ->
-      oauth_plaintext:signature(consumer_secret(Consumer), TokenSecret);
-    hmac_sha1 ->
-      BaseString = signature_base_string(HttpMethod, URL, Params),
-      oauth_hmac_sha1:signature(BaseString, consumer_secret(Consumer), TokenSecret);
-    rsa_sha1 ->
-      BaseString = signature_base_string(HttpMethod, URL, Params),
-      oauth_rsa_sha1:signature(BaseString, consumer_secret(Consumer))
-  end.
+signature_method(_Consumer={_, _, Method}) ->
+  Method.
 
-signature_base_string(HttpMethod, URL, Params) ->
-  NormalizedURL = oauth_uri:normalize(URL),
-  NormalizedParams = oauth_uri:params_to_string(lists:sort(Params)),
-  oauth_uri:calate("&", [HttpMethod, NormalizedURL, NormalizedParams]).
+sign(HttpMethod, URL, Params, Consumer, Token, TokenSecret) ->
+  SignatureParams = signature_params(Consumer, Params, Token),
+  Signature = signature(HttpMethod, URL, SignatureParams, Consumer, TokenSecret),
+  [{"oauth_signature", Signature} | SignatureParams].
 
-token_param("", Params) ->
-  Params;
-token_param(Token, Params) ->
-  [{"oauth_token", Token}|Params].
+signature_params(Consumer, Params, "") ->
+  signature_params(Consumer, Params);
+signature_params(Consumer, Params, Token) ->
+  signature_params(Consumer, [{"oauth_token", Token} | Params]).
 
-params(Consumer, Params) ->
+signature_params(Consumer, Params) ->
+  Timestamp = unix_timestamp(),
   Nonce = base64:encode_to_string(crypto:rand_bytes(32)), % cf. ruby-oauth
-  params(Consumer, oauth_unix:timestamp(), Nonce, Params).
-
-params(Consumer, Timestamp, Nonce, Params) ->
   [ {"oauth_version", "1.0"}
   , {"oauth_nonce", Nonce}
   , {"oauth_timestamp", integer_to_list(Timestamp)}
@@ -87,6 +86,26 @@ params(Consumer, Timestamp, Nonce, Params) ->
   | Params
   ].
 
+verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret) ->
+  case signature_method(Consumer) of
+    plaintext ->
+      plaintext_verify(Signature, Consumer, TokenSecret);
+    hmac_sha1 ->
+      hmac_sha1_verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret);
+    rsa_sha1 ->
+      rsa_sha1_verify(Signature, HttpMethod, URL, Params, Consumer)
+  end.
+
+signature(HttpMethod, URL, Params, Consumer, TokenSecret) ->
+  case signature_method(Consumer) of
+    plaintext ->
+      plaintext_signature(Consumer, TokenSecret);
+    hmac_sha1 ->
+      hmac_sha1_signature(HttpMethod, URL, Params, Consumer, TokenSecret);
+    rsa_sha1 ->
+      rsa_sha1_signature(HttpMethod, URL, Params, Consumer)
+  end.
+
 signature_method_string(Consumer) ->
   case signature_method(Consumer) of
     plaintext ->
@@ -97,11 +116,200 @@ signature_method_string(Consumer) ->
       "RSA-SHA1"
   end.
 
-signature_method(_Consumer={_, _, Method}) ->
-  Method.
+plaintext_signature(Consumer, TokenSecret) ->
+  uri_join([consumer_secret(Consumer), TokenSecret]).
 
-consumer_secret(_Consumer={_, Secret, _}) ->
-  Secret.
+plaintext_verify(Signature, Consumer, TokenSecret) ->
+  verify_in_constant_time(Signature, plaintext_signature(Consumer, TokenSecret)).
 
-consumer_key(_Consumer={Key, _, _}) ->
+hmac_sha1_signature(HttpMethod, URL, Params, Consumer, TokenSecret) ->
+  BaseString = signature_base_string(HttpMethod, URL, Params),
+  hmac_sha1_signature(BaseString, Consumer, TokenSecret).
+
+hmac_sha1_signature(BaseString, Consumer, TokenSecret) ->
+  Key = uri_join([consumer_secret(Consumer), TokenSecret]),
+  base64:encode_to_string(crypto:sha_mac(Key, BaseString)).
+
+hmac_sha1_verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret) ->
+  verify_in_constant_time(Signature, hmac_sha1_signature(HttpMethod, URL, Params, Consumer, TokenSecret)).
+
+hmac_sha1_verify(Signature, BaseString, Consumer, TokenSecret) ->
+  verify_in_constant_time(Signature, hmac_sha1_signature(BaseString, Consumer, TokenSecret)).
+
+rsa_sha1_signature(HttpMethod, URL, Params, Consumer) ->
+  BaseString = signature_base_string(HttpMethod, URL, Params),
+  rsa_sha1_signature(BaseString, Consumer).
+
+rsa_sha1_signature(BaseString, Consumer) ->
+  Key = read_private_key(consumer_secret(Consumer)),
+  base64:encode_to_string(public_key:sign(list_to_binary(BaseString), sha, Key)).
+
+rsa_sha1_verify(Signature, HttpMethod, URL, Params, Consumer) ->
+  BaseString = signature_base_string(HttpMethod, URL, Params),
+  rsa_sha1_verify(Signature, BaseString, Consumer).
+
+rsa_sha1_verify(Signature, BaseString, Consumer) ->
+  Key = read_cert_key(consumer_secret(Consumer)),
+  public_key:verify(to_binary(BaseString), sha, base64:decode(Signature), Key).
+
+verify_in_constant_time(<<X/binary>>, <<Y/binary>>) ->
+  verify_in_constant_time(binary_to_list(X), binary_to_list(Y));
+verify_in_constant_time(X, Y) when is_list(X) and is_list(Y) ->
+  case length(X) == length(Y) of
+    true ->
+      verify_in_constant_time(X, Y, 0);
+    false ->
+      false
+  end.
+
+verify_in_constant_time([X | RestX], [Y | RestY], Result) ->
+  verify_in_constant_time(RestX, RestY, (X bxor Y) bor Result);
+verify_in_constant_time([], [], Result) ->
+  Result == 0.
+
+signature_base_string(HttpMethod, URL, Params) ->
+  uri_join([HttpMethod, uri_normalize(URL), params_encode(Params)]).
+
+params_encode(Params) ->
+  % cf. http://tools.ietf.org/html/rfc5849#section-3.4.1.3.2
+  Encoded = [{uri_encode(K), uri_encode(V)} || {K, V} <- Params],
+  Sorted = lists:sort(Encoded),
+  Concatenated = [lists:concat([K, "=", V]) || {K, V} <- Sorted],
+  string:join(Concatenated, "&").
+
+params_decode(_Response={{_, _, _}, _, Body}) ->
+  uri_params_decode(Body).
+
+http_request(Method, Request, Options) ->
+  httpc:request(Method, Request, [{autoredirect, false}], Options).
+
+unix_timestamp() ->
+  unix_timestamp(calendar:universal_time()).
+
+unix_timestamp(DateTime) ->
+  unix_seconds(DateTime) - unix_epoch().
+
+unix_epoch() ->
+  unix_seconds({{1970,1,1},{00,00,00}}).
+
+unix_seconds(DateTime) ->
+  calendar:datetime_to_gregorian_seconds(DateTime).
+
+read_cert_key(Path) when is_list(Path) ->
+  {ok, Contents} = file:read_file(Path),
+  [{'Certificate', DerCert, not_encrypted}] = public_key:pem_decode(Contents),
+  read_cert_key(public_key:pkix_decode_cert(DerCert, otp));
+read_cert_key(#'OTPCertificate'{tbsCertificate=Cert}) ->
+  read_cert_key(Cert);
+read_cert_key(#'OTPTBSCertificate'{subjectPublicKeyInfo=Info}) ->
+  read_cert_key(Info);
+read_cert_key(#'OTPSubjectPublicKeyInfo'{subjectPublicKey=Key}) ->
   Key.
+
+read_private_key(Path) ->
+  {ok, Contents} = file:read_file(Path),
+  [Info] = public_key:pem_decode(Contents),
+  public_key:pem_entry_decode(Info).
+
+to_binary(Term) when is_list(Term) ->
+  list_to_binary(Term);
+to_binary(Term) when is_binary(Term) ->
+  Term.
+
+header_params_encode(Params) ->
+  intercalate(", ", [lists:concat([uri_encode(K), "=\"", uri_encode(V), "\""]) || {K, V} <- Params]).
+
+header_params_decode(String) ->
+  [header_param_decode(Param) || Param <- re:split(String, ",\\s*", [{return, list}]), Param =/= ""].
+
+header_param_decode(Param) ->
+  [Key, QuotedValue] = string:tokens(Param, "="),
+  Value = string:substr(QuotedValue, 2, length(QuotedValue) - 2),
+  {uri_decode(Key), uri_decode(Value)}.
+
+uri_normalize(URI) ->
+  case http_uri:parse(URI) of
+    {ok, {Scheme, UserInfo, Host, Port, Path, _Query}} -> % R15B
+      uri_normalize(Scheme, UserInfo, string:to_lower(Host), Port, [Path]);
+    {Scheme, UserInfo, Host, Port, Path, _Query} ->
+      uri_normalize(Scheme, UserInfo, string:to_lower(Host), Port, [Path]);
+    Else ->
+      Else
+  end.
+
+uri_normalize(http, UserInfo, Host, 80, Acc) ->
+  uri_normalize(http, UserInfo, [Host|Acc]);
+uri_normalize(https, UserInfo, Host, 443, Acc) ->
+  uri_normalize(https, UserInfo, [Host|Acc]);
+uri_normalize(Scheme, UserInfo, Host, Port, Acc) ->
+  uri_normalize(Scheme, UserInfo, [Host, ":", Port|Acc]).
+
+uri_normalize(Scheme, [], Acc) ->
+  lists:concat([Scheme, "://" | Acc]);
+uri_normalize(Scheme, UserInfo, Acc) ->
+  lists:concat([Scheme, "://", UserInfo, "@" | Acc]).
+
+uri_params_encode(Params) ->
+  intercalate("&", [uri_join([K, V], "=") || {K, V} <- Params]).
+
+uri_params_decode(String) ->
+  [uri_param_decode(Substring) || Substring <- string:tokens(String, "&")].
+
+uri_param_decode(String) ->
+  [Key, Value] = string:tokens(String, "="),
+  {uri_decode(Key), uri_decode(Value)}.
+
+uri_join(Values) ->
+  uri_join(Values, "&").
+
+uri_join(Values, Separator) ->
+  string:join([uri_encode(Value) || Value <- Values], Separator).
+
+intercalate(Sep, Xs) ->
+  lists:concat(intersperse(Sep, Xs)).
+
+intersperse(_, []) ->
+  [];
+intersperse(_, [X]) ->
+  [X];
+intersperse(Sep, [X | Xs]) ->
+  [X, Sep | intersperse(Sep, Xs)].
+
+uri_encode(Term) when is_integer(Term) ->
+  integer_to_list(Term);
+uri_encode(Term) when is_atom(Term) ->
+  uri_encode(atom_to_list(Term));
+uri_encode(Term) when is_list(Term) ->
+  uri_encode(lists:reverse(Term, []), []).
+
+-define(is_alphanum(C), C >= $A, C =< $Z; C >= $a, C =< $z; C >= $0, C =< $9).
+
+uri_encode([X | T], Acc) when ?is_alphanum(X); X =:= $-; X =:= $_; X =:= $.; X =:= $~ ->
+  uri_encode(T, [X | Acc]);
+uri_encode([X | T], Acc) ->
+  NewAcc = [$%, dec2hex(X bsr 4), dec2hex(X band 16#0f) | Acc],
+  uri_encode(T, NewAcc);
+uri_encode([], Acc) ->
+  Acc.
+
+uri_decode(Str) when is_list(Str) ->
+  uri_decode(Str, []).
+
+uri_decode([$%, A, B | T], Acc) ->
+  uri_decode(T, [(hex2dec(A) bsl 4) + hex2dec(B) | Acc]);
+uri_decode([X | T], Acc) ->
+  uri_decode(T, [X | Acc]);
+uri_decode([], Acc) ->
+  lists:reverse(Acc, []).
+
+-compile({inline, [{dec2hex, 1}, {hex2dec, 1}]}).
+
+dec2hex(N) when N >= 10 andalso N =< 15 ->
+  N + $A - 10;
+dec2hex(N) when N >= 0 andalso N =< 9 ->
+  N + $0.
+
+hex2dec(C) when C >= $A andalso C =< $F ->
+  C - $A + 10;
+hex2dec(C) when C >= $0 andalso C =< $9 ->
+  C - $0.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/oauth_hmac_sha1.erl
----------------------------------------------------------------------
diff --git a/oauth_hmac_sha1.erl b/oauth_hmac_sha1.erl
deleted file mode 100644
index 35549cf..0000000
--- a/oauth_hmac_sha1.erl
+++ /dev/null
@@ -1,11 +0,0 @@
--module(oauth_hmac_sha1).
-
--export([signature/3, verify/4]).
-
-
-signature(BaseString, CS, TS) ->
-  Key = oauth_uri:calate("&", [CS, TS]),
-  base64:encode_to_string(crypto:sha_mac(Key, BaseString)).
-
-verify(Signature, BaseString, CS, TS) ->
-  couch_util:verify(Signature, signature(BaseString, CS, TS)).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/oauth_http.erl
----------------------------------------------------------------------
diff --git a/oauth_http.erl b/oauth_http.erl
deleted file mode 100644
index 92c806c..0000000
--- a/oauth_http.erl
+++ /dev/null
@@ -1,22 +0,0 @@
--module(oauth_http).
-
--export([get/1, post/2, response_params/1, response_body/1, response_code/1]).
-
-
-get(URL) ->
-  request(get, {URL, []}).
-
-post(URL, Data) ->
-  request(post, {URL, [], "application/x-www-form-urlencoded", Data}).
-
-request(Method, Request) ->
-  httpc:request(Method, Request, [{autoredirect, false}], []).
-
-response_params(Response) ->
-  oauth_uri:params_from_string(response_body(Response)).
-
-response_body({{_, _, _}, _, Body}) ->
-  Body.
-
-response_code({{_, Code, _}, _, _}) ->
-  Code.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/oauth_plaintext.erl
----------------------------------------------------------------------
diff --git a/oauth_plaintext.erl b/oauth_plaintext.erl
deleted file mode 100644
index 9544a0a..0000000
--- a/oauth_plaintext.erl
+++ /dev/null
@@ -1,10 +0,0 @@
--module(oauth_plaintext).
-
--export([signature/2, verify/3]).
-
-
-signature(CS, TS) ->
-  oauth_uri:calate("&", [CS, TS]).
-
-verify(Signature, CS, TS) ->
-  couch_util:verify(Signature, signature(CS, TS)).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/oauth_rsa_sha1.erl
----------------------------------------------------------------------
diff --git a/oauth_rsa_sha1.erl b/oauth_rsa_sha1.erl
deleted file mode 100644
index 6f4828e..0000000
--- a/oauth_rsa_sha1.erl
+++ /dev/null
@@ -1,30 +0,0 @@
--module(oauth_rsa_sha1).
-
--export([signature/2, verify/3]).
-
--include_lib("public_key/include/public_key.hrl").
-
-
-signature(BaseString, PrivateKeyPath) ->
-  {ok, [Info]} = public_key:pem_to_der(PrivateKeyPath),
-  {ok, PrivateKey} = public_key:decode_private_key(Info),
-  base64:encode_to_string(public_key:sign(list_to_binary(BaseString), PrivateKey)).
-
-verify(Signature, BaseString, PublicKey) ->
-  public_key:verify_signature(to_binary(BaseString), sha, base64:decode(Signature), public_key(PublicKey)).
-
-to_binary(Term) when is_list(Term) ->
-  list_to_binary(Term);
-to_binary(Term) when is_binary(Term) ->
-  Term.
-
-public_key(Path) when is_list(Path) ->
-  {ok, [{cert, DerCert, not_encrypted}]} = public_key:pem_to_der(Path),
-  {ok, Cert} = public_key:pkix_decode_cert(DerCert, otp),
-  public_key(Cert);
-public_key(#'OTPCertificate'{tbsCertificate=Cert}) ->
-  public_key(Cert);
-public_key(#'OTPTBSCertificate'{subjectPublicKeyInfo=Info}) ->
-  public_key(Info);
-public_key(#'OTPSubjectPublicKeyInfo'{subjectPublicKey=Key}) ->
-  Key.

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/oauth_unix.erl
----------------------------------------------------------------------
diff --git a/oauth_unix.erl b/oauth_unix.erl
deleted file mode 100644
index 73ca314..0000000
--- a/oauth_unix.erl
+++ /dev/null
@@ -1,16 +0,0 @@
--module(oauth_unix).
-
--export([timestamp/0]).
-
-
-timestamp() ->
-  timestamp(calendar:universal_time()).
-
-timestamp(DateTime) ->
-  seconds(DateTime) - epoch().
-
-epoch() ->
-  seconds({{1970,1,1},{00,00,00}}).
-
-seconds(DateTime) ->
-  calendar:datetime_to_gregorian_seconds(DateTime).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/db23ab23/oauth_uri.erl
----------------------------------------------------------------------
diff --git a/oauth_uri.erl b/oauth_uri.erl
deleted file mode 100644
index aebf093..0000000
--- a/oauth_uri.erl
+++ /dev/null
@@ -1,100 +0,0 @@
--module(oauth_uri).
-
--export([normalize/1, calate/2, encode/1]).
--export([params_from_string/1, params_to_string/1,
-  params_from_header_string/1, params_to_header_string/1]).
-
--import(lists, [concat/1]).
-
-
-normalize(URI) ->
-  case http_uri:parse(URI) of
-    {ok, {Scheme, UserInfo, Host, Port, Path, _Query}} -> % R15B
-        normalize(Scheme, UserInfo, string:to_lower(Host), Port, [Path]);
-    {Scheme, UserInfo, Host, Port, Path, _Query} ->
-      normalize(Scheme, UserInfo, string:to_lower(Host), Port, [Path]);
-    Else ->
-      Else
-  end.
-
-normalize(http, UserInfo, Host, 80, Acc) ->
-  normalize(http, UserInfo, [Host|Acc]);
-normalize(https, UserInfo, Host, 443, Acc) ->
-  normalize(https, UserInfo, [Host|Acc]);
-normalize(Scheme, UserInfo, Host, Port, Acc) ->
-  normalize(Scheme, UserInfo, [Host, ":", Port|Acc]).
-
-normalize(Scheme, [], Acc) ->
-  concat([Scheme, "://"|Acc]);
-normalize(Scheme, UserInfo, Acc) ->
-  concat([Scheme, "://", UserInfo, "@"|Acc]).
-
-params_to_header_string(Params) ->
-  intercalate(", ", [concat([encode(K), "=\"", encode(V), "\""]) || {K, V} <- Params]).
-
-params_from_header_string(String) ->
-  [param_from_header_string(Param) || Param <- re:split(String, ",\\s*", [{return, list}]), Param =/= ""].
-
-param_from_header_string(Param) ->
-  [Key, QuotedValue] = string:tokens(Param, "="),
-  Value = string:substr(QuotedValue, 2, length(QuotedValue) - 2),
-  {decode(Key), decode(Value)}.
-
-params_from_string(Params) ->
-  [param_from_string(Param) || Param <- string:tokens(Params, "&")].
-
-param_from_string(Param) ->
-  list_to_tuple([decode(Value) || Value <- string:tokens(Param, "=")]).
-
-params_to_string(Params) ->
-  intercalate("&", [calate("=", [K, V]) || {K, V} <- Params]).
-
-calate(Sep, Xs) ->
-  intercalate(Sep, [encode(X) || X <- Xs]).
-
-intercalate(Sep, Xs) ->
-  concat(intersperse(Sep, Xs)).
-
-intersperse(_, []) -> [];
-intersperse(_, [X]) -> [X];
-intersperse(Sep, [X|Xs]) ->
-  [X, Sep|intersperse(Sep, Xs)].
-
--define(is_alphanum(C), C >= $A, C =< $Z; C >= $a, C =< $z; C >= $0, C =< $9).
-
-encode(Term) when is_integer(Term) ->
-  integer_to_list(Term);
-encode(Term) when is_atom(Term) ->
-  encode(atom_to_list(Term));
-encode(Term) when is_list(Term) ->
-  encode(lists:reverse(Term, []), []).
-
-encode([X | T], Acc) when ?is_alphanum(X); X =:= $-; X =:= $_; X =:= $.; X =:= $~ ->
-  encode(T, [X | Acc]);
-encode([X | T], Acc) ->
-  NewAcc = [$%, dec2hex(X bsr 4), dec2hex(X band 16#0f) | Acc],
-  encode(T, NewAcc);
-encode([], Acc) ->
-  Acc.
-
-decode(Str) when is_list(Str) ->
-  decode(Str, []).
-
-decode([$%, A, B | T], Acc) ->
-  decode(T, [(hex2dec(A) bsl 4) + hex2dec(B) | Acc]);
-decode([X | T], Acc) ->
-  decode(T, [X | Acc]);
-decode([], Acc) ->
-  lists:reverse(Acc, []).
-
--compile({inline, [{dec2hex, 1}, {hex2dec, 1}]}).
-
-dec2hex(N) when N >= 10 andalso N =< 15 ->
-  N + $A - 10;
-dec2hex(N) when N >= 0 andalso N =< 9 ->
-  N + $0.
-
-hex2dec(C) when C >= $A andalso C =< $F ->
-  C - $A + 10;
-hex2dec(C) when C >= $0 andalso C =< $9 ->
-  C - $0.


[05/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
all hail paul davis

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@819780 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/7cc148bf
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/7cc148bf
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/7cc148bf

Branch: refs/heads/import-master
Commit: 7cc148bfb1c9e7df486913e1d83342430c1cc9fa
Parents: 8f360c1
Author: Noah Slater <ns...@apache.org>
Authored: Tue Sep 29 00:07:28 2009 +0000
Committer: Noah Slater <ns...@apache.org>
Committed: Tue Sep 29 00:07:28 2009 +0000

----------------------------------------------------------------------
 Makefile.am | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/7cc148bf/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 5cc3270..c87d7f6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,6 @@ oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
 oauth_file_collection = \
     oauth.erl \
     oauth_hmac_sha1.erl \
-#   oauth_rsa_sha1.erl \
     oauth_http.erl \
     oauth_plaintext.erl \
     oauth_unix.erl \
@@ -29,7 +28,6 @@ oauthebin_static_file = oauth.app
 oauthebin_make_generated_file_list = \
     oauth.beam \
     oauth_hmac_sha1.beam \
-#   oauth_rsa_sha1.beam \
     oauth_http.beam \
     oauth_plaintext.beam \
     oauth_unix.beam \


[03/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
added rsa module

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@819773 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/eb3f773c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/eb3f773c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/eb3f773c

Branch: refs/heads/import-master
Commit: eb3f773c9dca968b2c3545601afe9917046a33a3
Parents: 95c501f
Author: Noah Slater <ns...@apache.org>
Authored: Mon Sep 28 23:56:42 2009 +0000
Committer: Noah Slater <ns...@apache.org>
Committed: Mon Sep 28 23:56:42 2009 +0000

----------------------------------------------------------------------
 Makefile.am | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/eb3f773c/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index c87d7f6..71b4aa3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,6 +18,7 @@ oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
 oauth_file_collection = \
     oauth.erl \
     oauth_hmac_sha1.erl \
+    oauth_rsa_sha1.erl \
     oauth_http.erl \
     oauth_plaintext.erl \
     oauth_unix.erl \
@@ -28,6 +29,7 @@ oauthebin_static_file = oauth.app
 oauthebin_make_generated_file_list = \
     oauth.beam \
     oauth_hmac_sha1.beam \
+    oauth_rsa_sha1.beam \
     oauth_http.beam \
     oauth_plaintext.beam \
     oauth_unix.beam \


[10/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
restore couch_util:verify call in oauth.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/07b034b5
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/07b034b5
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/07b034b5

Branch: refs/heads/import-master
Commit: 07b034b5cfff60dad4d4465831cfeb80fd35a5ff
Parents: d8594f7
Author: Robert Newson <rn...@apache.org>
Authored: Thu Oct 13 15:09:02 2011 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Thu Oct 13 15:09:32 2011 +0100

----------------------------------------------------------------------
 oauth_hmac_sha1.erl | 2 +-
 oauth_plaintext.erl | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/07b034b5/oauth_hmac_sha1.erl
----------------------------------------------------------------------
diff --git a/oauth_hmac_sha1.erl b/oauth_hmac_sha1.erl
index 69064ed..35549cf 100644
--- a/oauth_hmac_sha1.erl
+++ b/oauth_hmac_sha1.erl
@@ -8,4 +8,4 @@ signature(BaseString, CS, TS) ->
   base64:encode_to_string(crypto:sha_mac(Key, BaseString)).
 
 verify(Signature, BaseString, CS, TS) ->
-  Signature =:= signature(BaseString, CS, TS).
+  couch_util:verify(Signature, signature(BaseString, CS, TS)).

http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/07b034b5/oauth_plaintext.erl
----------------------------------------------------------------------
diff --git a/oauth_plaintext.erl b/oauth_plaintext.erl
index d8085e0..9544a0a 100644
--- a/oauth_plaintext.erl
+++ b/oauth_plaintext.erl
@@ -7,4 +7,4 @@ signature(CS, TS) ->
   oauth_uri:calate("&", [CS, TS]).
 
 verify(Signature, CS, TS) ->
-  Signature =:= signature(CS, TS).
+  couch_util:verify(Signature, signature(CS, TS)).


[08/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
added oauth_rsa_sha1.erl to the dist

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@984237 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/fb60e650
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/fb60e650
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/fb60e650

Branch: refs/heads/import-master
Commit: fb60e650c2b90314a416ba28bee7bd2747bf9672
Parents: a24be94
Author: Noah Slater <ns...@apache.org>
Authored: Tue Aug 10 22:17:12 2010 +0000
Committer: Noah Slater <ns...@apache.org>
Committed: Tue Aug 10 22:17:12 2010 +0000

----------------------------------------------------------------------
 Makefile.am | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/fb60e650/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 1d12339..48b7648 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,18 +12,19 @@
 
 oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
 
-# Removed oauth_rsa_sha1.erl until we require R12B5 or
-# we add a ./configure option to enable it.
-
 oauth_file_collection = \
 	oauth.app.in \
     oauth.erl \
     oauth_hmac_sha1.erl \
     oauth_http.erl \
     oauth_plaintext.erl \
+    oauth_rsa_sha1.erl \
     oauth_unix.erl \
     oauth_uri.erl
 
+# Removed oauth_rsa_sha1.beam until we require R12B5 or
+# we add a ./configure option to enable it.
+
 oauthebin_make_generated_file_list = \
 	oauth.app \
     oauth.beam \


[04/12] oauth commit: updated refs/heads/import-master to db23ab2

Posted by da...@apache.org.
commented out line

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@819778 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/8f360c14
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/8f360c14
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/8f360c14

Branch: refs/heads/import-master
Commit: 8f360c14692a46b4b4f2304e0235c1aa55365792
Parents: eb3f773
Author: Noah Slater <ns...@apache.org>
Authored: Tue Sep 29 00:03:47 2009 +0000
Committer: Noah Slater <ns...@apache.org>
Committed: Tue Sep 29 00:03:47 2009 +0000

----------------------------------------------------------------------
 Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/8f360c14/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 71b4aa3..5cc3270 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,7 @@ oauthebindir = $(localerlanglibdir)/erlang-oauth/ebin
 oauth_file_collection = \
     oauth.erl \
     oauth_hmac_sha1.erl \
-    oauth_rsa_sha1.erl \
+#   oauth_rsa_sha1.erl \
     oauth_http.erl \
     oauth_plaintext.erl \
     oauth_unix.erl \
@@ -29,7 +29,7 @@ oauthebin_static_file = oauth.app
 oauthebin_make_generated_file_list = \
     oauth.beam \
     oauth_hmac_sha1.beam \
-    oauth_rsa_sha1.beam \
+#   oauth_rsa_sha1.beam \
     oauth_http.beam \
     oauth_plaintext.beam \
     oauth_unix.beam \