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 2016/05/15 15:17:59 UTC

chttpd commit: updated refs/heads/master to 408d218

Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 7cffe7edc -> 408d218e1


disable cassim until fixed


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

Branch: refs/heads/master
Commit: 408d218e1516790d734997a5b1935a8fbf5d9779
Parents: 7cffe7e
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri May 13 12:55:38 2016 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Fri May 13 15:05:09 2016 +0200

----------------------------------------------------------------------
 src/chttpd.app.src          |  3 +-
 src/chttpd_auth_request.erl |  2 +-
 src/chttpd_db.erl           | 74 ++++++----------------------------------
 src/chttpd_external.erl     |  2 +-
 4 files changed, 14 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/408d218e/src/chttpd.app.src
----------------------------------------------------------------------
diff --git a/src/chttpd.app.src b/src/chttpd.app.src
index 2230849..5561994 100644
--- a/src/chttpd.app.src
+++ b/src/chttpd.app.src
@@ -40,8 +40,7 @@
         config,
         couch,
         ets_lru,
-        fabric,
-        cassim
+        fabric
     ]},
     {mod, {chttpd_app,[]}}
 ]}.

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/408d218e/src/chttpd_auth_request.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_auth_request.erl b/src/chttpd_auth_request.erl
index 5d85cb0..b05c91f 100644
--- a/src/chttpd_auth_request.erl
+++ b/src/chttpd_auth_request.erl
@@ -76,7 +76,7 @@ server_authorization_check(#httpd{path_parts=[<<"_", _/binary>>|_]}=Req) ->
     require_admin(Req).
 
 db_authorization_check(#httpd{path_parts=[DbName|_],user_ctx=Ctx}=Req) ->
-    {_} = cassim:get_security(DbName, [{user_ctx, Ctx}]),
+    {_} = fabric:get_security(DbName, [{user_ctx, Ctx}]),
     Req.
 
 require_admin(Req) ->

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/408d218e/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index 9347c1a..09cea5b 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -291,7 +291,7 @@ delete_db_req(#httpd{}=Req, DbName) ->
     end.
 
 do_db_req(#httpd{path_parts=[DbName|_], user_ctx=Ctx}=Req, Fun) ->
-    cassim:get_security(DbName, [{user_ctx,Ctx}]), % calls check_is_reader
+    fabric:get_security(DbName, [{user_ctx,Ctx}]), % calls check_is_reader
     Fun(Req, #db{name=DbName, user_ctx=Ctx}).
 
 db_req(#httpd{method='GET',path_parts=[DbName]}=Req, _Db) ->
@@ -545,25 +545,22 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_revs_diff">>]}=Req, Db) ->
 db_req(#httpd{path_parts=[_,<<"_revs_diff">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "POST");
 
-%% DEPRECATED: this endpoint functionality will be replaced by _security_mvcc
-db_req(#httpd{method='PUT',path_parts=[_,<<"_security">>]}=Req, Db) ->
-    put_security(Req, Db, true);
+db_req(#httpd{method='PUT',path_parts=[_,<<"_security">>],user_ctx=Ctx}=Req,
+        Db) ->
+    SecObj = chttpd:json_body(Req),
+    case fabric:set_security(Db, SecObj, [{user_ctx, Ctx}]) of
+        ok ->
+            send_json(Req, {[{<<"ok">>, true}]});
+        Else ->
+            throw(Else)
+    end;
 
 db_req(#httpd{method='GET',path_parts=[_,<<"_security">>],user_ctx=Ctx}=Req, Db) ->
-    send_json(Req, cassim:get_security(Db, [{user_ctx,Ctx}]));
+    send_json(Req, fabric:get_security(Db));
 
 db_req(#httpd{path_parts=[_,<<"_security">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "PUT,GET");
 
-db_req(#httpd{method='PUT',path_parts=[_,<<"_security_mvcc">>]}=Req, Db) ->
-    put_security(Req, Db, false);
-
-db_req(#httpd{method='GET',path_parts=[_,<<"_security_mvcc">>],user_ctx=Ctx}=Req, Db) ->
-    send_json(Req, cassim:get_security(Db, [{user_ctx,Ctx}]));
-
-db_req(#httpd{path_parts=[_,<<"_security_mvcc">>]}=Req, _Db) ->
-    send_method_not_allowed(Req, "PUT,GET");
-
 db_req(#httpd{method='PUT',path_parts=[_,<<"_revs_limit">>],user_ctx=Ctx}=Req,
         Db) ->
     Limit = chttpd:json_body(Req),
@@ -1487,55 +1484,6 @@ monitor_attachments(Att) ->
 demonitor_refs(Refs) when is_list(Refs) ->
     [demonitor(Ref) || Ref <- Refs].
 
-%% This function should exist in cassim, but its depedence on the #httpd{}
-%% record makes it difficult to separate. This function should be refactored and
-%% moved into cassim once couch_doc_from_req and update_doc are reworked.
-put_security(#httpd{user_ctx=Ctx}=Req, Db, FetchRev) ->
-    case {cassim:is_enabled(), cassim:metadata_db_exists()} of
-        {true, true} ->
-            DbName = Db#db.name,
-            DocId = cassim_metadata_cache:security_meta_id(DbName),
-            {SecObj0} = chttpd:json_body(Req),
-            {OldSecDoc} = cassim:get_security(DbName),
-            OldRev = couch_util:get_value(<<"_rev">>, OldSecDoc, undefined),
-            %% Maybe update the security doc with the rev when hiding mvcc logic
-            SecObj = case {FetchRev, OldRev} of
-                %% User supplied rev, just use the req body
-                {false, _} ->
-                    SecObj0;
-                %% User did not supply rev, but new security doc
-                {true, undefined} ->
-                    SecObj0;
-                %% User did not supply rev, use the old rev
-                {true, OldRev} ->
-                    [{<<"_rev">>, OldRev}|proplists:delete(<<"_rev">>, SecObj0)]
-            end,
-            SecDoc = couch_doc_from_req(Req, DocId, {SecObj}),
-            Options = [
-                delay_commit,
-                interactive_edit,
-                {user_ctx, Ctx},
-                {w, integer_to_list(mem3:quorum(Db))}
-            ],
-            {Status, {etag, Etag}, Body} =
-                cassim:set_security(Db, SecDoc, Options),
-            HttpCode = http_code_from_status(Status),
-            ResponseHeaders = [{"Etag", Etag}],
-            send_json(Req, HttpCode, ResponseHeaders, Body);
-        {false, true} ->
-            throw({error, security_migration_updates_disabled});
-        %% handle completely disabled case and also cassim setting enabled but
-        %% metadata db does not exist.
-        _ ->
-            SecObj = chttpd:json_body(Req),
-            case fabric:set_security(Db, SecObj, [{user_ctx, Ctx}]) of
-                ok ->
-                    send_json(Req, {[{<<"ok">>, true}]});
-                Else ->
-                    throw(Else)
-            end
-    end.
-
 set_namespace(<<"_all_docs">>, Args) ->
     set_namespace(undefined, Args);
 set_namespace(<<"_local_docs">>, Args) ->

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/408d218e/src/chttpd_external.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_external.erl b/src/chttpd_external.erl
index f9bebed..a0850b1 100644
--- a/src/chttpd_external.erl
+++ b/src/chttpd_external.erl
@@ -123,7 +123,7 @@ get_db_info(#db{} = Db) ->
 
 
 get_db_security(#db{main_pid = nil}=Db, #user_ctx{}=UserCtx) ->
-    cassim:get_security(Db, [{user_ctx, UserCtx}]);
+    couch_db:get_security(Db);
 get_db_security(#db{}=Db, #user_ctx{}) ->
     couch_db:get_security(Db).