couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikewall...@apache.org
Subject couch commit: updated refs/heads/2452-users-db-security-on-clustered-interface to 633b7f1
Date Fri, 16 Jan 2015 17:14:43 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/2452-users-db-security-on-clustered-interface 4e24b4cae -> 633b7f1ee


[squash] Move users DB check into its own fun

The chain of orelse statements combined with the indentation was
pretty hard to read. This commit moves the checks into their own
function and uses lists:any (which also shortcircuits).


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

Branch: refs/heads/2452-users-db-security-on-clustered-interface
Commit: 633b7f1ee9e76cf9a8520b5878b87e0170d9f1a6
Parents: 4e24b4c
Author: Mike Wallace <mikewallace@apache.org>
Authored: Fri Jan 16 15:10:40 2015 +0000
Committer: Mike Wallace <mikewallace@apache.org>
Committed: Fri Jan 16 15:24:24 2015 +0000

----------------------------------------------------------------------
 src/couch_server.erl | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/633b7f1e/src/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_server.erl b/src/couch_server.erl
index 9e6ea70..024ab4d 100644
--- a/src/couch_server.erl
+++ b/src/couch_server.erl
@@ -116,6 +116,14 @@ create(DbName, Options0) ->
 delete(DbName, Options) ->
     gen_server:call(couch_server, {delete, DbName, Options}, infinity).
 
+is_users_db(DbName) ->
+    IsUsersDbPreds = [
+        fun() -> DbName == config:get("couch_httpd_auth", "authentication_db", "_users")
end,
+        fun() -> path_ends_with(DbName, <<"_users">>) end,
+        fun() -> binary_to_list(mem3:dbname(DbName)) == config:get("chttpd_auth", "authentication_db",
"_users") end
+    ],
+    lists:any(fun(F) -> F() end, IsUsersDbPreds).
+
 maybe_add_sys_db_callbacks(DbName, Options) when is_binary(DbName) ->
     maybe_add_sys_db_callbacks(?b2l(DbName), Options);
 maybe_add_sys_db_callbacks(DbName, Options) ->
@@ -123,10 +131,7 @@ maybe_add_sys_db_callbacks(DbName, Options) ->
     NodesDbName = config:get("mem3", "shard_db", "nodes"),
     IsReplicatorDb = DbName == config:get("replicator", "db", "_replicator") orelse
         path_ends_with(DbName, <<"_replicator">>),
-    IsUsersDb = DbName ==config:get("couch_httpd_auth", "authentication_db", "_users") orelse
-        path_ends_with(DbName, <<"_users">>) orelse
-            binary_to_list(mem3:dbname(DbName)) ==
-            config:get("chttpd_auth", "authentication_db", "_users"),
+    IsUsersDb = is_users_db(DbName),
     if
         DbName == DbsDbName ->
             [sys_db | Options];


Mime
View raw message