summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_db.erl
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2010-06-23 19:11:50 +0000
committerDamien F. Katz <damien@apache.org>2010-06-23 19:11:50 +0000
commitfeb18bd6efc40126bdb4af390419223e10ef134d (patch)
tree0833e401ab28327acf5f377bb929fe8d351502c8 /src/couchdb/couch_httpd_db.erl
parent918f8bf54a4aeffc3c0ef4ad1fa31ce93bbc1346 (diff)
Authentication caching, to avoid repeated opening and closing of the users database for each request requiring authentication. COUCHDB-807
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@957314 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_db.erl')
-rw-r--r--src/couchdb/couch_httpd_db.erl33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 87fc15d8..06d56c7b 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -160,23 +160,13 @@ handle_design_info_req(Req, _Db, _DDoc) ->
create_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) ->
ok = couch_httpd:verify_is_server_admin(Req),
- LDbName = ?b2l(DbName),
- case couch_config:get("couch_httpd_auth", "authentication_db") of
- LDbName ->
- % make sure user's db always has the auth ddoc
- {ok, Db} = couch_httpd_auth:ensure_users_db_exists(DbName),
- couch_db:close(Db),
- DbUrl = absolute_uri(Req, "/" ++ couch_util:url_encode(DbName)),
- send_json(Req, 201, [{"Location", DbUrl}], {[{ok, true}]});
- _Else ->
- case couch_server:create(DbName, [{user_ctx, UserCtx}]) of
- {ok, Db} ->
- couch_db:close(Db),
- DbUrl = absolute_uri(Req, "/" ++ couch_util:url_encode(DbName)),
- send_json(Req, 201, [{"Location", DbUrl}], {[{ok, true}]});
- Error ->
- throw(Error)
- end
+ case couch_server:create(DbName, [{user_ctx, UserCtx}]) of
+ {ok, Db} ->
+ couch_db:close(Db),
+ DbUrl = absolute_uri(Req, "/" ++ couch_util:url_encode(DbName)),
+ send_json(Req, 201, [{"Location", DbUrl}], {[{ok, true}]});
+ Error ->
+ throw(Error)
end.
delete_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) ->
@@ -189,15 +179,6 @@ delete_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) ->
end.
do_db_req(#httpd{user_ctx=UserCtx,path_parts=[DbName|_]}=Req, Fun) ->
- LDbName = ?b2l(DbName),
- % I hope this lookup is cheap.
- case couch_config:get("couch_httpd_auth", "authentication_db") of
- LDbName ->
- % make sure user's db always has the auth ddoc
- {ok, ADb} = couch_httpd_auth:ensure_users_db_exists(DbName),
- couch_db:close(ADb);
- _Else -> ok
- end,
case couch_db:open(DbName, [{user_ctx, UserCtx}]) of
{ok, Db} ->
try