mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
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.
This commit is contained in:
parent
3516d2053c
commit
faaee94060
@ -19,7 +19,7 @@
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
{deps, [{base64url, ".*", {git, "https://github.com/dvv/base64url", {tag, "1.0.1"}}},
|
||||
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.26"}}},
|
||||
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", "4eadf230e2803e2ff1ef656641c6574001523f77"}},
|
||||
{eimp, ".*", {git, "https://github.com/processone/eimp", {tag, "1.0.18"}}},
|
||||
{if_var_true, tools,
|
||||
{ejabberd_po, ".*", {git, "https://github.com/processone/ejabberd-po", {branch, "main"}}}},
|
||||
|
@ -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) ->
|
||||
|
@ -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}).
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user