incubator-couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filipe Manana (JIRA)" <>
Subject [jira] Commented: (COUCHDB-912) Anonymous Access to Design Docs on private DB's
Date Sat, 06 Nov 2010 12:55:44 GMT


Filipe Manana commented on COUCHDB-912:


I have a few remarks:

1) A test is needed. Probably the right place for it will be in share/www/script/test/design_docs.js;

2) No need to change couch_db:open/2. Just use couch_db:open_int/2;

3) I agree with Adam. No need to "cache" the value. A couch_config:get/3 doesn't go through
a gen_server, it does direct lookups to a protected (readable by any process) ets table, therefore
it's very fast. I also don't think that couch_httpd.erl should be touched at all;

4) That to_bool/1 function is very unerlangish. Just do something like:   Whatever =:= "true";

5) Also that is_design_attachment function seems redundant. I would suggest restricting all
the change in couch_http_db.erl to the do_db_req/2 function. Something like the following:

diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 87fc15d..9e68c08 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -188,7 +188,7 @@ delete_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) ->
-do_db_req(#httpd{user_ctx=UserCtx,path_parts=[DbName|_]}=Req, Fun) ->
+do_db_req(#httpd{user_ctx=UserCtx,path_parts=[DbName|RestParts]}=Req, Fun) ->
     LDbName = ?b2l(DbName),
     % I hope this lookup is cheap.
     case couch_config:get("couch_httpd_auth", "authentication_db") of
@@ -198,7 +198,13 @@ do_db_req(#httpd{user_ctx=UserCtx,path_parts=[DbName|_]}=Req, Fun) ->
         _Else -> ok
-    case couch_db:open(DbName, [{user_ctx, UserCtx}]) of
+    OpenDbFun = case RestParts of
+    [<<"_design">> | _] ->
+        fun couch_db:open_int/2;
+    _ ->
+        fun couch_db:open/2
+    end,
+    case OpenDbFun(DbName, [{user_ctx, UserCtx}]) of
     {ok, Db} ->
             Fun(Req, Db)

All the rest seems ok to me. Good work.

> Anonymous Access to Design Docs on private DB's
> -----------------------------------------------
>                 Key: COUCHDB-912
>                 URL:
>             Project: CouchDB
>          Issue Type: New Feature
>          Components: HTTP Interface
>            Reporter: Dale Harvey
>         Attachments: anon.patch, anon.patch
> Right now people need to go through futon in order to login to couchapps running on private
databases, this is a pretty big limitation on the type of couchapps that can be built
> Propose adding the ability for users to flag the design docs as readable for anonymous
users, could be implemented though an attribute on the design doc?

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message