couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [8/9] git commit: Don't fallback to using fabric:set_security
Date Fri, 01 Aug 2014 09:05:01 GMT
Don't fallback to using fabric:set_security

The return values from cassim:set_security are different than those in
fabric:set_security. This removes the fallback clause to simplify the
logic and moves the is_enabled check out into chttpd.

BugzId: 32070


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

Branch: refs/heads/windsor-merge
Commit: 8f1812d20da351fc6f7abe58b5a6726db0c2e679
Parents: 80a17b0
Author: Russell Branca <chewbranca@apache.org>
Authored: Thu Jul 3 13:16:03 2014 -0700
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 30 18:18:33 2014 +0100

----------------------------------------------------------------------
 src/cassim_security.erl | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/8f1812d2/src/cassim_security.erl
----------------------------------------------------------------------
diff --git a/src/cassim_security.erl b/src/cassim_security.erl
index 250ce9d..0622b8c 100644
--- a/src/cassim_security.erl
+++ b/src/cassim_security.erl
@@ -75,25 +75,20 @@ set_security(DbName, SecProps) ->
     set_security(DbName, SecProps, [?ADMIN_CTX]).
 
 
-set_security(#db{name=DbName0}=Db, #doc{body=SecProps}=SecDoc0, Options) ->
-    case cassim_metadata_cache:metadata_db_exists() of
-        true ->
-            DbName = mem3:dbname(DbName0),
-            MetaId = cassim_metadata_cache:security_meta_id(DbName),
-            SecDoc = SecDoc0#doc{id=MetaId},
-            UserCtx = couch_util:get_value(user_ctx, Options, #user_ctx{}),
-            MetaDbName = cassim_metadata_cache:metadata_db(),
-            MetaDb = #db{name=MetaDbName, user_ctx=?ADMIN_USER},
-            cassim:verify_admin_role(UserCtx),
-            ok = validate_security_doc(SecDoc),
-            {Status, Etag, {Body0}} =
-                chttpd_db:update_doc(MetaDb, MetaId, SecDoc, Options),
-            Body = {proplists:delete(<<"_id">>, Body0)},
-            ok = cassim_metadata_cache:cleanup_old_docs(MetaId),
-            {Status, Etag, Body};
-        false ->
-            fabric:set_security(Db, SecProps, Options)
-    end.
+set_security(#db{name=DbName0}, #doc{}=SecDoc0, Options) ->
+    DbName = mem3:dbname(DbName0),
+    MetaId = cassim_metadata_cache:security_meta_id(DbName),
+    SecDoc = SecDoc0#doc{id=MetaId},
+    UserCtx = couch_util:get_value(user_ctx, Options, #user_ctx{}),
+    MetaDbName = cassim_metadata_cache:metadata_db(),
+    MetaDb = #db{name=MetaDbName, user_ctx=?ADMIN_USER},
+    cassim:verify_admin_role(UserCtx),
+    ok = validate_security_doc(SecDoc),
+    {Status, Etag, {Body0}} =
+        chttpd_db:update_doc(MetaDb, MetaId, SecDoc, Options),
+    Body = {proplists:delete(<<"_id">>, Body0)},
+    ok = cassim_metadata_cache:cleanup_old_docs(MetaId),
+    {Status, Etag, Body}.
 
 
 migrate_security_props(DbName0, {SecProps}) ->


Mime
View raw message