You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by mi...@apache.org on 2015/07/15 12:20:26 UTC
[1/2] fabric commit: updated refs/heads/master to 3c204d0
Repository: couchdb-fabric
Updated Branches:
refs/heads/master 405922c5d -> 3c204d009
Move is_*_db funs and helpers to fabric_util
This commit moves the is_*_db/1 funs and their helpers from
fabric_doc_update to fabric_util and exports them so they
can be re-used elsewhere in fabric.
COUCHDB-2738
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/c30665dc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/c30665dc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/c30665dc
Branch: refs/heads/master
Commit: c30665dcee9f5eeffc74ec03a5c7e50ed4d7c3b8
Parents: 405922c
Author: Mike Wallace <mi...@apache.org>
Authored: Wed Jul 15 10:50:21 2015 +0100
Committer: Mike Wallace <mi...@apache.org>
Committed: Wed Jul 15 10:53:36 2015 +0100
----------------------------------------------------------------------
src/fabric_doc_update.erl | 20 ++------------------
src/fabric_util.erl | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c30665dc/src/fabric_doc_update.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_update.erl b/src/fabric_doc_update.erl
index a39efad..58bd355 100644
--- a/src/fabric_doc_update.erl
+++ b/src/fabric_doc_update.erl
@@ -99,8 +99,8 @@ handle_message({bad_request, Msg}, _, _) ->
throw({bad_request, Msg}).
before_doc_update(DbName, Docs, Opts) ->
- Db = fake_db(Opts),
- case {is_replicator_db(DbName), is_users_db(DbName)} of
+ Db = fabric_util:fake_db(Opts),
+ case {fabric_util:is_replicator_db(DbName), fabric_util:is_users_db(DbName)} of
{true, _} ->
[couch_replicator_manager:before_doc_update(Doc, Db) || Doc <- Docs];
{_, true} ->
@@ -109,22 +109,6 @@ before_doc_update(DbName, Docs, Opts) ->
Docs
end.
-is_replicator_db(DbName) ->
- ConfigName = list_to_binary(config:get("replicator", "db", "_replicator")),
- DbName == ConfigName orelse path_ends_with(DbName, <<"_replicator">>).
-
-is_users_db(DbName) ->
- ConfigName = list_to_binary(config:get(
- "chttpd_auth", "authentication_db", "_users")),
- DbName == ConfigName orelse path_ends_with(DbName, <<"_users">>).
-
-path_ends_with(Path, Suffix) ->
- Suffix == couch_db:normalize_dbname(Path).
-
-fake_db(Opts) ->
- UserCtx = couch_util:get_value(user_ctx, Opts, #user_ctx{}),
- #db{user_ctx = UserCtx}.
-
tag_docs([]) ->
[];
tag_docs([#doc{meta=Meta}=Doc | Rest]) ->
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c30665dc/src/fabric_util.erl
----------------------------------------------------------------------
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index c5249d1..7b2ed75 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -18,6 +18,7 @@
-export([request_timeout/0, attachments_timeout/0, all_docs_timeout/0]).
-export([stream_start/2, stream_start/4]).
-export([log_timeout/2, remove_done_workers/2]).
+-export([is_users_db/1, is_replicator_db/1, fake_db/1]).
-compile({inline, [{doc_id_and_rev,1}]}).
@@ -281,6 +282,22 @@ remove_ancestors_test() ->
remove_ancestors([kv(Bar2,1), kv(Bar1,1)], [])
).
+is_replicator_db(DbName) ->
+ ConfigName = list_to_binary(config:get("replicator", "db", "_replicator")),
+ DbName == ConfigName orelse path_ends_with(DbName, <<"_replicator">>).
+
+is_users_db(DbName) ->
+ ConfigName = list_to_binary(config:get(
+ "chttpd_auth", "authentication_db", "_users")),
+ DbName == ConfigName orelse path_ends_with(DbName, <<"_users">>).
+
+path_ends_with(Path, Suffix) ->
+ Suffix == couch_db:normalize_dbname(Path).
+
+fake_db(Opts) ->
+ UserCtx = couch_util:get_value(user_ctx, Opts, #user_ctx{}),
+ #db{user_ctx = UserCtx}.
+
%% test function
kv(Item, Count) ->
{make_key(Item), {Item,Count}}.
[2/2] fabric commit: updated refs/heads/master to 3c204d0
Posted by mi...@apache.org.
Restrict views in the authentication DB to admins
This commit teaches fabric to restrict access to views in the
authentication DB to administrators by calling through to
couch_db_users:after_doc_read/2 after the design doc is read.
COUCHDB-2738
This closes #23
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/3c204d00
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/3c204d00
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/3c204d00
Branch: refs/heads/master
Commit: 3c204d00967318d14d767316c14639d1ba8f1d23
Parents: c30665d
Author: Mike Wallace <mi...@apache.org>
Authored: Wed Jul 15 10:54:05 2015 +0100
Committer: Mike Wallace <mi...@apache.org>
Committed: Wed Jul 15 11:16:30 2015 +0100
----------------------------------------------------------------------
src/fabric.erl | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3c204d00/src/fabric.erl
----------------------------------------------------------------------
diff --git a/src/fabric.erl b/src/fabric.erl
index c3a95fb..c1e0cd5 100644
--- a/src/fabric.erl
+++ b/src/fabric.erl
@@ -315,6 +315,14 @@ query_view(Db, GroupId, ViewName, Callback, Acc0, QueryArgs)
query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs);
query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs0) ->
Db = dbname(DbName), View = name(ViewName),
+ case fabric_util:is_users_db(Db) of
+ true ->
+ Req = Acc0#vacc.req,
+ FakeDb = fabric_util:fake_db([{user_ctx, Req#httpd.user_ctx}]),
+ couch_users_db:after_doc_read(DDoc, FakeDb);
+ false ->
+ ok
+ end,
{ok, #mrst{views=Views, language=Lang}} =
couch_mrview_util:ddoc_to_mrst(Db, DDoc),
QueryArgs1 = couch_mrview_util:set_view_type(QueryArgs0, View, Views),