couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject chttpd commit: updated refs/heads/master to 1f148b7
Date Mon, 02 Jun 2014 13:44:39 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 018837c95 -> 1f148b7b9


Check admins in config file for chttpd_auth


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

Branch: refs/heads/master
Commit: 1f148b7b98a798470e8f12684d2e834b1cb20006
Parents: 018837c
Author: Robert Newson <rnewson@apache.org>
Authored: Mon Jun 2 14:44:25 2014 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Jun 2 14:44:25 2014 +0100

----------------------------------------------------------------------
 src/chttpd_auth_cache.erl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/1f148b7b/src/chttpd_auth_cache.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_auth_cache.erl b/src/chttpd_auth_cache.erl
index e0c403b..14fd3ce 100644
--- a/src/chttpd_auth_cache.erl
+++ b/src/chttpd_auth_cache.erl
@@ -36,6 +36,20 @@ start_link() ->
 get_user_creds(UserName) when is_list(UserName) ->
     get_user_creds(?l2b(UserName));
 get_user_creds(UserName) when is_binary(UserName) ->
+    case couch_auth_cache:get_admin(UserName) of
+    nil ->
+        get_from_cache(UserName);
+    Props ->
+        case get_from_cache(UserName) of
+        nil ->
+            Props;
+        UserProps when is_list(UserProps) ->
+            couch_auth_cache:add_roles(Props,
+	        couch_util:get_value(<<"roles">>, UserProps))
+        end
+    end.
+
+get_from_cache(UserName) ->
     try ets_lru:lookup_d(?CACHE, UserName) of
 	{ok, Props} ->
 	    couch_stats_collector:increment({chttpd, auth_cache_hits}),


Mime
View raw message