couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davisp <...@git.apache.org>
Subject [GitHub] couchdb-couch pull request: Add users db security rules on cluster...
Date Tue, 24 Mar 2015 01:30:32 GMT
Github user davisp commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/20#discussion_r26997498
  
    --- Diff: src/couch_server.erl ---
    @@ -116,30 +116,37 @@ 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) ->
         DbsDbName = config:get("mem3", "shard_db", "dbs"),
         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">>),
    +        path_ends_with(DbName, <<"_replicator">>),
    +    IsUsersDb = is_users_db(DbName),
         if
    -	DbName == DbsDbName ->
    -	    [sys_db | Options];
    -	DbName == NodesDbName ->
    -	    [sys_db | Options];
    -	IsReplicatorDb ->
    -	    [{before_doc_update, fun couch_replicator_manager:before_doc_update/2},
    -	     {after_doc_read, fun couch_replicator_manager:after_doc_read/2},
    -	     sys_db | Options];
    -	IsUsersDb ->
    -	    [{before_doc_update, fun couch_users_db:before_doc_update/2},
    -	     {after_doc_read, fun couch_users_db:after_doc_read/2},
    -	     sys_db | Options];
    -	true ->
    -	    Options
    +        DbName == DbsDbName ->
    +            [sys_db | Options];
    +        DbName == NodesDbName ->
    +            [sys_db | Options];
    +        IsReplicatorDb ->
    +            [{before_doc_update, fun couch_replicator_manager:before_doc_update/2},
    +             {after_doc_read, fun couch_replicator_manager:after_doc_read/2},
    +             sys_db | Options];
    +        IsUsersDb ->
    +            [{before_doc_update, fun couch_users_db:before_doc_update/2},
    +             {after_doc_read, fun couch_users_db:after_doc_read/2},
    +             sys_db | Options];
    +        true ->
    +            Options
    --- End diff --
    
    Ixnay on the whitespace only changes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message