aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2021-01-27 11:23:39 +0100
committerPaweł Chmielowski <pchmielowski@process-one.net>2021-01-27 11:23:39 +0100
commitfaaee94060b63c8e3716344d1d64d66de3e8bb1c (patch)
tree35f86328b419d3a142a498ca79b29f18e8bb6925 /src
parentAdd 'ejabberdctl foreground-quiet' (diff)
Add oauth_cache_rest_failure_life_time option
This allows to use shorted life time for failures in rest oauth backend than specified in oauth_cache_life_time.
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd_oauth_rest.erl5
-rw-r--r--src/ejabberd_option.erl5
-rw-r--r--src/ejabberd_options.erl4
-rw-r--r--src/mod_muc_opt.erl28
4 files changed, 27 insertions, 15 deletions
diff --git a/src/ejabberd_oauth_rest.erl b/src/ejabberd_oauth_rest.erl
index d0448abab..af5e8267f 100644
--- a/src/ejabberd_oauth_rest.erl
+++ b/src/ejabberd_oauth_rest.erl
@@ -81,7 +81,10 @@ lookup(Token) ->
error;
Other ->
?ERROR_MSG("Unexpected response for oauth lookup: ~p", [Other]),
- error
+ case ejabberd_option:oauth_cache_rest_failure_life_time() of
+ infinity -> error;
+ Time -> {cache_with_timeout, error, Time}
+ end
end.
clean(_TS) ->
diff --git a/src/ejabberd_option.erl b/src/ejabberd_option.erl
index 873f76ed1..33e9f5738 100644
--- a/src/ejabberd_option.erl
+++ b/src/ejabberd_option.erl
@@ -83,6 +83,7 @@
-export([oauth_access/0, oauth_access/1]).
-export([oauth_cache_life_time/0]).
-export([oauth_cache_missed/0]).
+-export([oauth_cache_rest_failure_life_time/0]).
-export([oauth_cache_size/0]).
-export([oauth_client_id_check/0, oauth_client_id_check/1]).
-export([oauth_db_type/0]).
@@ -635,6 +636,10 @@ oauth_cache_life_time() ->
oauth_cache_missed() ->
ejabberd_config:get_option({oauth_cache_missed, global}).
+-spec oauth_cache_rest_failure_life_time() -> 'infinity' | pos_integer().
+oauth_cache_rest_failure_life_time() ->
+ ejabberd_config:get_option({oauth_cache_rest_failure_life_time, global}).
+
-spec oauth_cache_size() -> 'infinity' | pos_integer().
oauth_cache_size() ->
ejabberd_config:get_option({oauth_cache_size, global}).
diff --git a/src/ejabberd_options.erl b/src/ejabberd_options.erl
index 445a3515b..87d7ff91f 100644
--- a/src/ejabberd_options.erl
+++ b/src/ejabberd_options.erl
@@ -247,6 +247,8 @@ opt_type(oauth_cache_life_time) ->
econf:timeout(second, infinity);
opt_type(oauth_cache_missed) ->
econf:bool();
+opt_type(oauth_cache_rest_failure_life_time) ->
+ econf:timeout(second, infinity);
opt_type(oauth_cache_size) ->
econf:pos_int(infinity);
opt_type(oauth_db_type) ->
@@ -586,6 +588,7 @@ options() ->
fun(Host) -> ejabberd_config:get_option({cache_missed, Host}) end},
{oauth_cache_size,
fun(Host) -> ejabberd_config:get_option({cache_size, Host}) end},
+ {oauth_cache_rest_failure_life_time, infinity},
{oauth_db_type,
fun(Host) -> ejabberd_config:default_db(Host, ejabberd_oauth) end},
{oauth_expire, 4294967},
@@ -726,6 +729,7 @@ globals() ->
oauth_cache_life_time,
oauth_cache_missed,
oauth_cache_size,
+ oauth_cache_rest_failure_life_time,
oauth_db_type,
oauth_expire,
oauth_use_cache,
diff --git a/src/mod_muc_opt.erl b/src/mod_muc_opt.erl
index e0988137e..760a5d7c8 100644
--- a/src/mod_muc_opt.erl
+++ b/src/mod_muc_opt.erl
@@ -15,11 +15,11 @@
-export([history_size/1]).
-export([host/1]).
-export([hosts/1]).
+-export([max_captcha_whitelist/1]).
+-export([max_password/1]).
-export([max_room_desc/1]).
-export([max_room_id/1]).
-export([max_room_name/1]).
--export([max_password/1]).
--export([max_captcha_whitelist/1]).
-export([max_rooms_discoitems/1]).
-export([max_user_conferences/1]).
-export([max_users/1]).
@@ -109,6 +109,18 @@ hosts(Opts) when is_map(Opts) ->
hosts(Host) ->
gen_mod:get_module_opt(Host, mod_muc, hosts).
+-spec max_captcha_whitelist(gen_mod:opts() | global | binary()) -> 'infinity' | pos_integer().
+max_captcha_whitelist(Opts) when is_map(Opts) ->
+ gen_mod:get_opt(max_captcha_whitelist, Opts);
+max_captcha_whitelist(Host) ->
+ gen_mod:get_module_opt(Host, mod_muc, max_captcha_whitelist).
+
+-spec max_password(gen_mod:opts() | global | binary()) -> 'infinity' | pos_integer().
+max_password(Opts) when is_map(Opts) ->
+ gen_mod:get_opt(max_password, Opts);
+max_password(Host) ->
+ gen_mod:get_module_opt(Host, mod_muc, max_password).
+
-spec max_room_desc(gen_mod:opts() | global | binary()) -> 'infinity' | pos_integer().
max_room_desc(Opts) when is_map(Opts) ->
gen_mod:get_opt(max_room_desc, Opts);
@@ -127,18 +139,6 @@ max_room_name(Opts) when is_map(Opts) ->
max_room_name(Host) ->
gen_mod:get_module_opt(Host, mod_muc, max_room_name).
--spec max_password(gen_mod:opts() | global | binary()) -> 'infinity' | pos_integer().
-max_password(Opts) when is_map(Opts) ->
- gen_mod:get_opt(max_password, Opts);
-max_password(Host) ->
- gen_mod:get_module_opt(Host, mod_muc, max_password).
-
--spec max_captcha_whitelist(gen_mod:opts() | global | binary()) -> 'infinity' | pos_integer().
-max_captcha_whitelist(Opts) when is_map(Opts) ->
- gen_mod:get_opt(max_captcha_whitelist, Opts);
-max_captcha_whitelist(Host) ->
- gen_mod:get_module_opt(Host, mod_muc, max_captcha_whitelist).
-
-spec max_rooms_discoitems(gen_mod:opts() | global | binary()) -> non_neg_integer().
max_rooms_discoitems(Opts) when is_map(Opts) ->
gen_mod:get_opt(max_rooms_discoitems, Opts);