couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [2/2] git commit: Make just /_users/_changes admin-only, not every _changes
Date Tue, 21 Feb 2012 20:00:10 GMT
Make just /_users/_changes admin-only, not every _changes


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

Branch: refs/heads/master
Commit: fd0ca45d2d63ae33cccf10eed024a219113a51d6
Parents: 6dc9424
Author: Jan Lehnardt <jan@apache.org>
Authored: Tue Feb 21 20:57:53 2012 +0100
Committer: Jan Lehnardt <jan@apache.org>
Committed: Tue Feb 21 20:57:53 2012 +0100

----------------------------------------------------------------------
 src/couchdb/couch_httpd_db.erl |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/fd0ca45d/src/couchdb/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index bba9b7c..981c6a1 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -63,8 +63,19 @@ handle_changes_req(#httpd{method='GET'}=Req, Db) ->
 handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "GET,HEAD,POST").
 
-handle_changes_req1(Req, Db) ->
-    ok = couch_db:check_is_admin(Db),
+handle_changes_req1(Req, #db{name=DbName}=Db) ->
+    AuthDbName = ?l2b(couch_config:get("couch_httpd_auth", "authentication_db")),
+    case AuthDbName of
+    DbName ->
+        % in the authentication database, _changes is admin-only.
+        ok = couch_db:check_is_admin(Db);
+    _Else ->
+        % on other databases, _changes is free for all.
+        ok
+    end,
+    handle_changes_req2(Req, Db).
+
+handle_changes_req2(Req, Db) ->
     MakeCallback = fun(Resp) ->
         fun({change, Change, _}, "continuous") ->
             send_chunk(Resp, [?JSON_ENCODE(Change) | "\n"]);


Mime
View raw message