couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject couch commit: updated refs/heads/master to db78f68
Date Sun, 15 May 2016 19:13:52 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master aef448db0 -> db78f6827


Allow customisation of default security object

COUCHDB-3016


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

Branch: refs/heads/master
Commit: db78f6827109ee1b41bceedf7eadd629c6044cc9
Parents: aef448d
Author: Robert Newson <rnewson@apache.org>
Authored: Tue May 10 20:59:38 2016 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Sun May 15 20:10:49 2016 +0100

----------------------------------------------------------------------
 src/couch_db_updater.erl | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/db78f682/src/couch_db_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl
index 813161a..28022a8 100644
--- a/src/couch_db_updater.erl
+++ b/src/couch_db_updater.erl
@@ -570,7 +570,7 @@ init_db(DbName, Filepath, Fd, Header0, Options) ->
         [{compression, Compression}]),
     case couch_db_header:security_ptr(Header) of
     nil ->
-        Security = [],
+        Security = default_security_object(),
         SecurityPtr = nil;
     SecurityPtr ->
         {ok, Security} = couch_file:pread_term(Fd, SecurityPtr)
@@ -1437,3 +1437,12 @@ make_doc_summary(#db{compression = Comp}, {Body0, Atts0}) ->
     end,
     SummaryBin = ?term_to_bin({Body, Atts}),
     couch_file:assemble_file_chunk(SummaryBin, couch_crypto:hash(md5, SummaryBin)).
+
+default_security_object() ->
+    case config:get("couchdb", "default_security", "open") of
+        "admin_only" ->
+            [{<<"members">>,{[{<<"roles">>,[<<"_admin">>]}]}},
+             {<<"admins">>,{[{<<"roles">>,[<<"_admin">>]}]}}];
+        "everyone" ->
+            []
+    end.


Mime
View raw message