couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/2] git commit: Make just /_users/_changes admin-only, not every _changes
Date Tue, 21 Feb 2012 20:00:10 GMT
Updated Branches:
  refs/heads/1.2.x 8c76f98b2 -> 4c7799722
  refs/heads/master 6dc942496 -> fd0ca45d2


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/4c779972
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4c779972
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4c779972

Branch: refs/heads/1.2.x
Commit: 4c779972248ff61332acf3032e40253547ee9d95
Parents: 8c76f98
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:58:10 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/4c779972/src/couchdb/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 07a7a2d..9f68002 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