You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2017/10/31 17:50:22 UTC

[couchdb] branch revert-dedup-detection created (now 3cbba75)

This is an automated email from the ASF dual-hosted git repository.

jan pushed a change to branch revert-dedup-detection
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 3cbba75  Revert "faet: reject user docs with duplicate keys"

This branch includes the following new commits:

     new 3cbba75  Revert "faet: reject user docs with duplicate keys"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].

[couchdb] 01/01: Revert "faet: reject user docs with duplicate keys"

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch revert-dedup-detection
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 3cbba751e75af0f828f291a80aa6b462dcfced2d
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Oct 31 18:50:06 2017 +0100

    Revert "faet: reject user docs with duplicate keys"
    
    This reverts commit 42adcc1a0849f65f9ef4d55aafe11b3aa59512a9.
---
 src/chttpd/src/chttpd_auth_cache.erl | 52 +++++++-----------------------------
 src/couch/src/couch_users_db.erl     | 22 ---------------
 2 files changed, 10 insertions(+), 64 deletions(-)

diff --git a/src/chttpd/src/chttpd_auth_cache.erl b/src/chttpd/src/chttpd_auth_cache.erl
index 48a6ed4..4d85b16 100644
--- a/src/chttpd/src/chttpd_auth_cache.erl
+++ b/src/chttpd/src/chttpd_auth_cache.erl
@@ -218,47 +218,15 @@ maybe_validate_user_creds(nil) ->
 % throws if UserCreds includes a _conflicts member
 % returns UserCreds otherwise
 maybe_validate_user_creds(UserCreds) ->
-    ok = validate_conflicts(UserCreds),
-    ok = validate_dupes(UserCreds),
-    {ok, UserCreds, nil}.
-
-
-validate_conflicts(UserCreds) ->
-    AllowConflictedUserDocs = config:get_boolean("chttpd_auth",
-        "allow_conflicted_user_docs", false),
-    Conflicts = couch_util:get_value(<<"_conflicts">>, UserCreds, false),
-    Throw = {unauthorized,
-        <<"User document conflicts must be resolved before the document",
-        " is used for authentication purposes.">>},
-    case {Conflicts, AllowConflictedUserDocs} of
-        {false, _} ->
-            ok;
+    AllowConflictedUserDocs = config:get_boolean("chttpd_auth", "allow_conflicted_user_docs", false),
+    case {couch_util:get_value(<<"_conflicts">>, UserCreds), AllowConflictedUserDocs} of
+        {undefined, _} ->
+            {ok, UserCreds, nil};
         {_, true} ->
-            ok;
-        {_, false} ->
-            throw(Throw)
-    end.
-
-
-validate_dupes(UserCreds) ->
-    AllowDupedUserDocs = config:get_boolean("chttpd_auth",
-        "allow_user_docs_with_duplicate_keys", false),
-    Dupes = has_dupes(UserCreds),
-    Throw = {unauthorized,
-        <<"User document duplicate keys must be removed before the document",
-          " is used for authentication purposes.">>},
-    case {Dupes, AllowDupedUserDocs} of
-        {false, _} ->
-            ok;
-        {_, true} ->
-            ok;
-        {_, false} ->
-            throw(Throw)
-    end.
-
-
-has_dupes(UserCreds) ->
-    case couch_users_db:is_valid_doc_body(UserCreds) of
-        true -> false;
-        _ -> true
+            {ok, UserCreds, nil};
+        {_ConflictList, false} ->
+            throw({unauthorized,
+                <<"User document conflicts must be resolved before the document",
+                  " is used for authentication purposes.">>
+            })
     end.
diff --git a/src/couch/src/couch_users_db.erl b/src/couch/src/couch_users_db.erl
index 75d6b69..c7b41f1 100644
--- a/src/couch/src/couch_users_db.erl
+++ b/src/couch/src/couch_users_db.erl
@@ -13,7 +13,6 @@
 -module(couch_users_db).
 
 -export([before_doc_update/2, after_doc_read/2, strip_non_public_fields/1]).
--export([is_valid_doc_body/1]).
 
 -include_lib("couch/include/couch_db.hrl").
 
@@ -41,12 +40,6 @@
 % Else
 %   -> save_doc
 before_doc_update(Doc, Db) ->
-    case is_valid_doc_body(Doc#doc.body) of
-    true ->
-        ok;
-    false ->
-        throw({bad_request, "User docs must not contain duplicate fields."})
-    end,
     #user_ctx{name=Name} = couch_db:get_user_ctx(Db),
     DocName = get_doc_name(Doc),
     case (catch couch_db:check_is_admin(Db)) of
@@ -58,21 +51,6 @@ before_doc_update(Doc, Db) ->
         throw(not_found)
     end.
 
-% Make sure that _users db docs do not contain repeated
-% field names.
-is_valid_doc_body({Props}) ->
-    {Keys, Values} = lists:unzip(Props),
-    case length(Keys) == length(lists:usort(Keys)) of
-        true ->
-            lists:all(fun is_valid_doc_body/1, Values);
-        false ->
-            false
-    end;
-is_valid_doc_body(Values) when is_list(Values)->
-    lists:all(fun is_valid_doc_body/1, Values);
-is_valid_doc_body(_) ->
-    true.
-
 % If newDoc.password == null || newDoc.password == undefined:
 %   ->
 %   noop

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.