couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [19/50] couch-httpd commit: updated refs/heads/split_out_httpd_stack to e44a372
Date Tue, 01 Mar 2016 20:00:52 GMT
Merge the diff for verify_is_server_admin/1


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/commit/d2c5f480
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/d2c5f480
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/d2c5f480

Branch: refs/heads/split_out_httpd_stack
Commit: d2c5f4800e4e950383ce9150d97a84779bc56057
Parents: a8e03e2
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Fri Feb 26 09:58:07 2016 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Tue Mar 1 08:35:08 2016 -0800

----------------------------------------------------------------------
 src/couch_httpd.erl          |  4 +++-
 src/couch_httpd_original.erl | 12 +++---------
 2 files changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/d2c5f480/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index 53b98e3..ea91405 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -543,7 +543,9 @@ etag_respond(Req, CurrentEtag, RespFun) ->
         RespFun()
     end.
 
-verify_is_server_admin(#httpd{user_ctx=#user_ctx{roles=Roles}}) ->
+verify_is_server_admin(#httpd{user_ctx=UserCtx}) ->
+    verify_is_server_admin(UserCtx);
+verify_is_server_admin(#user_ctx{roles=Roles}) ->
     case lists:member(<<"_admin">>, Roles) of
     true -> ok;
     false -> throw({unauthorized, <<"You are not a server admin.">>})

http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/d2c5f480/src/couch_httpd_original.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_original.erl b/src/couch_httpd_original.erl
index abbce0e..98b334e 100644
--- a/src/couch_httpd_original.erl
+++ b/src/couch_httpd_original.erl
@@ -16,7 +16,7 @@
 -export([start_link/0, start_link/1, stop/0, handle_request/5]).
 
 
--export([verify_is_server_admin/1,error_info/1]).
+-export([error_info/1]).
 -export([make_fun_spec_strs/1]).
 
 
@@ -72,7 +72,8 @@
     validate_host/1,
     accepted_encodings/1,
     validate_referer/1,
-    validate_bind_address/1
+    validate_bind_address/1,
+    verify_is_server_admin/1
 ]).
 
 -define(HANDLER_NAME_IN_MODULE_POS, 6).
@@ -415,13 +416,6 @@ increment_method_stats(Method) ->
 
 
 
-verify_is_server_admin(#httpd{user_ctx=UserCtx}) ->
-    verify_is_server_admin(UserCtx);
-verify_is_server_admin(#user_ctx{roles=Roles}) ->
-    case lists:member(<<"_admin">>, Roles) of
-    true -> ok;
-    false -> throw({unauthorized, <<"You are not a server admin.">>})
-    end.
 
 error_info({Error, Reason}) when is_list(Reason) ->
     error_info({Error, ?l2b(Reason)});


Mime
View raw message