diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2019-01-30 14:56:52 +0300 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2019-01-30 14:57:03 +0300 |
commit | 62ad1e5e4fbfbbab848f56f10a97328d0675d501 (patch) | |
tree | bfd4dbbebc20f2e3023b56e9be9c095ae954af08 /src/mod_http_api.erl | |
parent | 23e5b3756c39df6028fdb38e57712016ba540a14 (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.erl | 10 |
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 |