You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2013/04/23 15:43:06 UTC
[1/5] git commit: updated refs/heads/1.1.x to a839f7e
Updated Branches:
refs/heads/1.1.x 16466f7fe -> a839f7e06
refs/heads/1.2.x 30b48e6a2 -> 7cdedb028
refs/heads/1.3.x bd0342d1a -> 9d41ea8a4
refs/heads/master 0838d8d61 -> ae6f1ebd8
Make cardinality of result explicit, remove join hacks
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a839f7e0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a839f7e0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a839f7e0
Branch: refs/heads/1.1.x
Commit: a839f7e06ef22d4c747e58d1b0e51dd587775e62
Parents: 43135c7
Author: Robert Newson <rn...@apache.org>
Authored: Mon Nov 19 10:55:57 2012 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Apr 23 14:30:39 2013 +0100
----------------------------------------------------------------------
share/www/script/test/users_db.js | 18 ++++++++++++++++++
src/couchdb/couch_httpd_auth.erl | 17 +++++++++--------
2 files changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a839f7e0/share/www/script/test/users_db.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/users_db.js b/share/www/script/test/users_db.js
index 1e13e5d..b2966b2 100644
--- a/share/www/script/test/users_db.js
+++ b/share/www/script/test/users_db.js
@@ -111,6 +111,24 @@ couchTests.users_db = function(debug) {
T(e.reason == "doc.roles must be an array");
}
jchrisUserDoc.roles = [];
+
+ // test that you can login as a user with a password starting with :
+ var doc = CouchDB.prepareUserDoc({
+ name: "foo@example.org"
+ }, ":bar");
+ T(usersDb.save(doc).ok);
+
+ T(CouchDB.session().userCtx.name == null);
+
+ // test that you can use basic auth aginst the users db
+ var s = CouchDB.session({
+ headers : {
+ // base64_encode("foo@example.org::bar")
+ "Authorization" : "Basic Zm9vQGV4YW1wbGUub3JnOjpiYXI="
+ }
+ });
+ T(s.userCtx.name == "foo@example.org");
+
};
usersDb.deleteDb();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a839f7e0/src/couchdb/couch_httpd_auth.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl
index 9f6ed18..1bd3a0d 100644
--- a/src/couchdb/couch_httpd_auth.erl
+++ b/src/couchdb/couch_httpd_auth.erl
@@ -26,7 +26,7 @@ special_test_authentication_handler(Req) ->
case header_value(Req, "WWW-Authenticate") of
"X-Couch-Test-Auth " ++ NamePass ->
% NamePass is a colon separated string: "joe schmoe:a password".
- [Name, Pass] = re:split(NamePass, ":", [{return, list}]),
+ [Name, Pass] = re:split(NamePass, ":", [{return, list}, {parts, 2}]),
case {Name, Pass} of
{"Jan Lehnardt", "apple"} -> ok;
{"Christopher Lenz", "dog food"} -> ok;
@@ -47,14 +47,13 @@ basic_name_pw(Req) ->
AuthorizationHeader = header_value(Req, "Authorization"),
case AuthorizationHeader of
"Basic " ++ Base64Value ->
- case string:tokens(?b2l(base64:decode(Base64Value)),":") of
+ case re:split(base64:decode(Base64Value), ":",
+ [{return, list}, {parts, 2}]) of
["_", "_"] ->
% special name and pass to be logged out
nil;
[User, Pass] ->
{User, Pass};
- [User | Pass] ->
- {User, string:join(Pass, ":")};
_ ->
nil
end;
@@ -161,9 +160,10 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
undefined -> Req;
[] -> Req;
Cookie ->
- [User, TimeStr | HashParts] = try
+ [User, TimeStr, HashStr] = try
AuthSession = couch_util:decodeBase64Url(Cookie),
- [_A, _B | _Cs] = string:tokens(?b2l(AuthSession), ":")
+ [_A, _B, _Cs] = re:split(?b2l(AuthSession), ":",
+ [{return, list}, {parts, 3}])
catch
_:_Error ->
Reason = <<"Malformed AuthSession cookie. Please clear your cookies.">>,
@@ -183,8 +183,9 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<"">>),
FullSecret = <<Secret/binary, UserSalt/binary>>,
ExpectedHash = crypto:sha_mac(FullSecret, User ++ ":" ++ TimeStr),
- Hash = ?l2b(string:join(HashParts, ":")),
- Timeout = to_int(couch_config:get("couch_httpd_auth", "timeout", 600)),
+ Hash = ?l2b(HashStr),
+ Timeout = list_to_integer(
+ couch_config:get("couch_httpd_auth", "timeout", "600")),
?LOG_DEBUG("timeout ~p", [Timeout]),
case (catch erlang:list_to_integer(TimeStr, 16)) of
TimeStamp when CurrentTime < TimeStamp + Timeout ->
[3/5] git commit: updated refs/heads/1.2.x to 7cdedb0
Posted by rn...@apache.org.
Make cardinality of result explicit, remove join hacks
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/7cdedb02
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/7cdedb02
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/7cdedb02
Branch: refs/heads/1.2.x
Commit: 7cdedb0282bcf274b80d4e552705756b925b8841
Parents: 30b48e6
Author: Robert Newson <rn...@apache.org>
Authored: Mon Nov 19 10:55:57 2012 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Apr 23 14:31:49 2013 +0100
----------------------------------------------------------------------
share/www/script/test/users_db.js | 18 ++++++++++++++++++
src/couchdb/couch_httpd_auth.erl | 14 +++++++-------
2 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/7cdedb02/share/www/script/test/users_db.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/users_db.js b/share/www/script/test/users_db.js
index 7648523..f52f022 100644
--- a/share/www/script/test/users_db.js
+++ b/share/www/script/test/users_db.js
@@ -122,6 +122,24 @@ couchTests.users_db = function(debug) {
} catch(e) {
TEquals("Character `:` is not allowed in usernames.", e.reason);
}
+
+ // test that you can login as a user with a password starting with :
+ var doc = CouchDB.prepareUserDoc({
+ name: "foo@example.org"
+ }, ":bar");
+ T(usersDb.save(doc).ok);
+
+ T(CouchDB.session().userCtx.name == null);
+
+ // test that you can use basic auth aginst the users db
+ var s = CouchDB.session({
+ headers : {
+ // base64_encode("foo@example.org::bar")
+ "Authorization" : "Basic Zm9vQGV4YW1wbGUub3JnOjpiYXI="
+ }
+ });
+ T(s.userCtx.name == "foo@example.org");
+
};
usersDb.deleteDb();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/7cdedb02/src/couchdb/couch_httpd_auth.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl
index a3ee4f4..508ec7f 100644
--- a/src/couchdb/couch_httpd_auth.erl
+++ b/src/couchdb/couch_httpd_auth.erl
@@ -26,7 +26,7 @@ special_test_authentication_handler(Req) ->
case header_value(Req, "WWW-Authenticate") of
"X-Couch-Test-Auth " ++ NamePass ->
% NamePass is a colon separated string: "joe schmoe:a password".
- [Name, Pass] = re:split(NamePass, ":", [{return, list}]),
+ [Name, Pass] = re:split(NamePass, ":", [{return, list}, {parts, 2}]),
case {Name, Pass} of
{"Jan Lehnardt", "apple"} -> ok;
{"Christopher Lenz", "dog food"} -> ok;
@@ -47,14 +47,13 @@ basic_name_pw(Req) ->
AuthorizationHeader = header_value(Req, "Authorization"),
case AuthorizationHeader of
"Basic " ++ Base64Value ->
- case string:tokens(?b2l(base64:decode(Base64Value)),":") of
+ case re:split(base64:decode(Base64Value), ":",
+ [{return, list}, {parts, 2}]) of
["_", "_"] ->
% special name and pass to be logged out
nil;
[User, Pass] ->
{User, Pass};
- [User | Pass] ->
- {User, string:join(Pass, ":")};
_ ->
nil
end;
@@ -161,9 +160,10 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
undefined -> Req;
[] -> Req;
Cookie ->
- [User, TimeStr | HashParts] = try
+ [User, TimeStr, HashStr] = try
AuthSession = couch_util:decodeBase64Url(Cookie),
- [_A, _B | _Cs] = string:tokens(?b2l(AuthSession), ":")
+ [_A, _B, _Cs] = re:split(?b2l(AuthSession), ":",
+ [{return, list}, {parts, 3}])
catch
_:_Error ->
Reason = <<"Malformed AuthSession cookie. Please clear your cookies.">>,
@@ -183,7 +183,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<"">>),
FullSecret = <<Secret/binary, UserSalt/binary>>,
ExpectedHash = crypto:sha_mac(FullSecret, User ++ ":" ++ TimeStr),
- Hash = ?l2b(string:join(HashParts, ":")),
+ Hash = ?l2b(HashStr),
Timeout = list_to_integer(
couch_config:get("couch_httpd_auth", "timeout", "600")),
?LOG_DEBUG("timeout ~p", [Timeout]),
[2/5] git commit: updated refs/heads/1.1.x to a839f7e
Posted by rn...@apache.org.
Fix configure.ac now AM_CONFIG_HEADER is gone
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/43135c78
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/43135c78
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/43135c78
Branch: refs/heads/1.1.x
Commit: 43135c781ac8d4f30f045f08f49bf006fbda57c2
Parents: 16466f7
Author: Robert Newson <rn...@apache.org>
Authored: Tue Apr 23 14:26:43 2013 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Apr 23 14:30:39 2013 +0100
----------------------------------------------------------------------
configure.ac | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/43135c78/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index e3c8ba5..5d634bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@ AC_CONFIG_SRCDIR([CHANGES])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
-AM_CONFIG_HEADER([config.h])
+AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([1.6.3 foreign])
[4/5] git commit: updated refs/heads/1.3.x to 9d41ea8
Posted by rn...@apache.org.
Make cardinality of result explicit, remove join hacks
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/9d41ea8a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/9d41ea8a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/9d41ea8a
Branch: refs/heads/1.3.x
Commit: 9d41ea8a474668f3d3f0c5d1fcdb13a77881c2b8
Parents: bd0342d
Author: Robert Newson <rn...@apache.org>
Authored: Mon Nov 19 10:55:57 2012 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Apr 23 14:34:55 2013 +0100
----------------------------------------------------------------------
share/www/script/test/users_db.js | 18 ++++++++++++++++++
src/couchdb/couch_httpd_auth.erl | 14 +++++++-------
2 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9d41ea8a/share/www/script/test/users_db.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/users_db.js b/share/www/script/test/users_db.js
index 44e6c88..6c57cb0 100644
--- a/share/www/script/test/users_db.js
+++ b/share/www/script/test/users_db.js
@@ -132,6 +132,24 @@ couchTests.users_db = function(debug) {
} catch(e) {
TEquals("Character `:` is not allowed in usernames.", e.reason);
}
+
+ // test that you can login as a user with a password starting with :
+ var doc = CouchDB.prepareUserDoc({
+ name: "foo@example.org"
+ }, ":bar");
+ T(usersDb.save(doc).ok);
+
+ T(CouchDB.session().userCtx.name == null);
+
+ // test that you can use basic auth aginst the users db
+ var s = CouchDB.session({
+ headers : {
+ // base64_encode("foo@example.org::bar")
+ "Authorization" : "Basic Zm9vQGV4YW1wbGUub3JnOjpiYXI="
+ }
+ });
+ T(s.userCtx.name == "foo@example.org");
+
};
usersDb.deleteDb();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9d41ea8a/src/couchdb/couch_httpd_auth.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl
index 5226a56..a967e09 100644
--- a/src/couchdb/couch_httpd_auth.erl
+++ b/src/couchdb/couch_httpd_auth.erl
@@ -26,7 +26,7 @@ special_test_authentication_handler(Req) ->
case header_value(Req, "WWW-Authenticate") of
"X-Couch-Test-Auth " ++ NamePass ->
% NamePass is a colon separated string: "joe schmoe:a password".
- [Name, Pass] = re:split(NamePass, ":", [{return, list}]),
+ [Name, Pass] = re:split(NamePass, ":", [{return, list}, {parts, 2}]),
case {Name, Pass} of
{"Jan Lehnardt", "apple"} -> ok;
{"Christopher Lenz", "dog food"} -> ok;
@@ -47,14 +47,13 @@ basic_name_pw(Req) ->
AuthorizationHeader = header_value(Req, "Authorization"),
case AuthorizationHeader of
"Basic " ++ Base64Value ->
- case string:tokens(?b2l(base64:decode(Base64Value)),":") of
+ case re:split(base64:decode(Base64Value), ":",
+ [{return, list}, {parts, 2}]) of
["_", "_"] ->
% special name and pass to be logged out
nil;
[User, Pass] ->
{User, Pass};
- [User | Pass] ->
- {User, string:join(Pass, ":")};
_ ->
nil
end;
@@ -158,9 +157,10 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
undefined -> Req;
[] -> Req;
Cookie ->
- [User, TimeStr | HashParts] = try
+ [User, TimeStr, HashStr] = try
AuthSession = couch_util:decodeBase64Url(Cookie),
- [_A, _B | _Cs] = re:split(?b2l(AuthSession), ":", [{return, list}])
+ [_A, _B, _Cs] = re:split(?b2l(AuthSession), ":",
+ [{return, list}, {parts, 3}])
catch
_:_Error ->
Reason = <<"Malformed AuthSession cookie. Please clear your cookies.">>,
@@ -180,7 +180,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<"">>),
FullSecret = <<Secret/binary, UserSalt/binary>>,
ExpectedHash = crypto:sha_mac(FullSecret, User ++ ":" ++ TimeStr),
- Hash = ?l2b(string:join(HashParts, ":")),
+ Hash = ?l2b(HashStr),
Timeout = list_to_integer(
couch_config:get("couch_httpd_auth", "timeout", "600")),
?LOG_DEBUG("timeout ~p", [Timeout]),
[5/5] git commit: updated refs/heads/master to ae6f1eb
Posted by rn...@apache.org.
Add tests for passwords beginning with :
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ae6f1ebd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ae6f1ebd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ae6f1ebd
Branch: refs/heads/master
Commit: ae6f1ebd8d0c63384050eb8c83b401a01095ad2c
Parents: 0838d8d
Author: Robert Newson <rn...@apache.org>
Authored: Mon Nov 19 10:55:57 2012 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Apr 23 14:37:19 2013 +0100
----------------------------------------------------------------------
share/www/script/test/users_db.js | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae6f1ebd/share/www/script/test/users_db.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/users_db.js b/share/www/script/test/users_db.js
index 4d6e4de..56dae6b 100644
--- a/share/www/script/test/users_db.js
+++ b/share/www/script/test/users_db.js
@@ -142,6 +142,24 @@ couchTests.users_db = function(debug) {
} catch(e) {
TEquals("Character `:` is not allowed in usernames.", e.reason);
}
+
+ // test that you can login as a user with a password starting with :
+ var doc = CouchDB.prepareUserDoc({
+ name: "foo@example.org"
+ }, ":bar");
+ T(usersDb.save(doc).ok);
+
+ T(CouchDB.session().userCtx.name == null);
+
+ // test that you can use basic auth aginst the users db
+ var s = CouchDB.session({
+ headers : {
+ // base64_encode("foo@example.org::bar")
+ "Authorization" : "Basic Zm9vQGV4YW1wbGUub3JnOjpiYXI="
+ }
+ });
+ T(s.userCtx.name == "foo@example.org");
+
};
usersDb.deleteDb();