25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Support ejabberd_auth_http's auth_opts (processone/ejabberd-contrib#284)

This commit is contained in:
Badlop 2020-02-03 18:23:00 +01:00
parent f0ba506fde
commit e234ced107
2 changed files with 25 additions and 0 deletions

View File

@ -15,6 +15,7 @@
-export([auth_cache_missed/0]). -export([auth_cache_missed/0]).
-export([auth_cache_size/0]). -export([auth_cache_size/0]).
-export([auth_method/0, auth_method/1]). -export([auth_method/0, auth_method/1]).
-export([auth_opts/0, auth_opts/1]).
-export([auth_password_format/0, auth_password_format/1]). -export([auth_password_format/0, auth_password_format/1]).
-export([auth_use_cache/0, auth_use_cache/1]). -export([auth_use_cache/0, auth_use_cache/1]).
-export([c2s_cafile/0, c2s_cafile/1]). -export([c2s_cafile/0, c2s_cafile/1]).
@ -220,6 +221,13 @@ auth_method() ->
auth_method(Host) -> auth_method(Host) ->
ejabberd_config:get_option({auth_method, Host}). ejabberd_config:get_option({auth_method, Host}).
-spec auth_opts() -> [{any(),any()}].
auth_opts() ->
auth_opts(global).
-spec auth_opts(global | binary()) -> [{any(),any()}].
auth_opts(Host) ->
ejabberd_config:get_option({auth_opts, Host}).
-spec auth_password_format() -> 'plain' | 'scram'. -spec auth_password_format() -> 'plain' | 'scram'.
auth_password_format() -> auth_password_format() ->
auth_password_format(global). auth_password_format(global).

View File

@ -62,6 +62,21 @@ opt_type(auth_cache_size) ->
econf:pos_int(infinity); econf:pos_int(infinity);
opt_type(auth_method) -> opt_type(auth_method) ->
econf:list_or_single(econf:db_type(ejabberd_auth)); econf:list_or_single(econf:db_type(ejabberd_auth));
opt_type(auth_opts) ->
fun(L) when is_list(L) ->
lists:map(
fun({host, V}) when is_binary(V) ->
{host, V};
({connection_pool_size, V}) when is_integer(V) ->
{connection_pool_size, V};
({connection_opts, V}) when is_list(V) ->
{connection_opts, V};
({basic_auth, V}) when is_binary(V) ->
{basic_auth, V};
({path_prefix, V}) when is_binary(V) ->
{path_prefix, V}
end, L)
end;
opt_type(auth_password_format) -> opt_type(auth_password_format) ->
econf:enum([plain, scram]); econf:enum([plain, scram]);
opt_type(auth_use_cache) -> opt_type(auth_use_cache) ->
@ -443,6 +458,7 @@ opt_type(jwt_auth_only_rule) ->
{disable_sasl_mechanisms, [binary()]} | {disable_sasl_mechanisms, [binary()]} |
{s2s_zlib, boolean()} | {s2s_zlib, boolean()} |
{loglevel, ejabberd_logger:loglevel()} | {loglevel, ejabberd_logger:loglevel()} |
{auth_opts, [{any(), any()}]} |
{listen, [ejabberd_listener:listener()]} | {listen, [ejabberd_listener:listener()]} |
{modules, [{module(), gen_mod:opts(), integer()}]} | {modules, [{module(), gen_mod:opts(), integer()}]} |
{ldap_uids, [{binary(), binary()}]} | {ldap_uids, [{binary(), binary()}]} |
@ -493,6 +509,7 @@ options() ->
fun(Host) -> ejabberd_config:get_option({cache_size, Host}) end}, fun(Host) -> ejabberd_config:get_option({cache_size, Host}) end},
{auth_method, {auth_method,
fun(Host) -> [ejabberd_config:default_db(Host, ejabberd_auth)] end}, fun(Host) -> [ejabberd_config:default_db(Host, ejabberd_auth)] end},
{auth_opts, []},
{auth_password_format, plain}, {auth_password_format, plain},
{auth_use_cache, {auth_use_cache,
fun(Host) -> ejabberd_config:get_option({use_cache, Host}) end}, fun(Host) -> ejabberd_config:get_option({use_cache, Host}) end},