Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2019-01-30 14:56:52 +0300
committerPaweł Chmielowski <pchmielowski@process-one.net>2019-01-30 14:57:03 +0300
commit62ad1e5e4fbfbbab848f56f10a97328d0675d501 (patch)
treebfd4dbbebc20f2e3023b56e9be9c095ae954af08 /src/mod_http_api.erl
parent23e5b3756c39df6028fdb38e57712016ba540a14 (diff)
Allow specifying tag for listener for api_permission purposes
This commit will allow adding tag to http listeners: listener: - port: 4000 - module: ejabberd_http - tag: "magic_listener" that later can be used to have special api_permission just for it: api_permissions: "magic_access": from: - tag: "magic_listener" who: all what: "*"
Diffstat (limited to 'src/mod_http_api.erl')
-rw-r--r--src/mod_http_api.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl
index 0d1d7c662..d31ca0f11 100644
--- a/src/mod_http_api.erl
+++ b/src/mod_http_api.erl
@@ -137,7 +137,7 @@ depends(_Host, _Opts) ->
%% basic auth
%% ----------
-extract_auth(#request{auth = HTTPAuth, ip = {IP, _}}) ->
+extract_auth(#request{auth = HTTPAuth, ip = {IP, _}, opts = Opts}) ->
Info = case HTTPAuth of
{SJID, Pass} ->
try jid:decode(SJID) of
@@ -163,13 +163,15 @@ extract_auth(#request{auth = HTTPAuth, ip = {IP, _}}) ->
end,
case Info of
Map when is_map(Map) ->
- Map#{caller_module => ?MODULE, ip => IP};
+ Tag = proplists:get_value(tag, Opts, <<>>),
+ Map#{caller_module => ?MODULE, ip => IP, tag => Tag};
_ ->
?DEBUG("Invalid auth data: ~p", [Info]),
Info
end;
-extract_auth(#request{ip = IP}) ->
- #{ip => IP, caller_module => ?MODULE}.
+extract_auth(#request{ip = IP, opts = Opts}) ->
+ Tag = proplists:get_value(tag, Opts, <<>>),
+ #{ip => IP, caller_module => ?MODULE, tag => Tag}.
%% ------------------
%% command processing