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

New option: disable_sasl_mechanisms

The new "disable_sasl_mechanisms" option allows for restricting the list
of SASL mechanisms offered to the client.

Closes #339.
This commit is contained in:
Holger Weiss 2014-11-10 01:10:04 +01:00
parent 1d2efcc168
commit ee0ecd2419
2 changed files with 30 additions and 3 deletions

View File

@ -1453,6 +1453,11 @@ The FQDN is used to authenticate some clients that use the DIGEST-MD5 SASL mecha
The option syntax is: The option syntax is:
\esyntax{fqdn: undefined|FqdnString|[FqdnString]} \esyntax{fqdn: undefined|FqdnString|[FqdnString]}
The option \option{disable\_sasl\_mechanisms} specifies a list of SASL
mechanisms that should \emph{not} be offered to the client. The mechanisms can
be listed as lowercase or uppercase strings. The option syntax is:
\esyntax{disable\_sasl\_mechanisms: [Mechanism, ...]}
\makesubsubsection{internalauth}{Internal} \makesubsubsection{internalauth}{Internal}
\ind{internal authentication}\ind{Mnesia} \ind{internal authentication}\ind{Mnesia}

View File

@ -93,9 +93,15 @@ start() ->
). ).
register_mechanism(Mechanism, Module, PasswordType) -> register_mechanism(Mechanism, Module, PasswordType) ->
ets:insert(sasl_mechanism, case is_disabled(Mechanism) of
#sasl_mechanism{mechanism = Mechanism, module = Module, false ->
password_type = PasswordType}). ets:insert(sasl_mechanism,
#sasl_mechanism{mechanism = Mechanism, module = Module,
password_type = PasswordType});
true ->
?DEBUG("SASL mechanism ~p is disabled", [Mechanism]),
true
end.
%%% TODO: use callbacks %%% TODO: use callbacks
%%-include("ejabberd.hrl"). %%-include("ejabberd.hrl").
@ -215,3 +221,19 @@ filter_anonymous(Host, Mechs) ->
true -> Mechs; true -> Mechs;
false -> Mechs -- [<<"ANONYMOUS">>] false -> Mechs -- [<<"ANONYMOUS">>]
end. end.
-spec(is_disabled/1 ::
(
Mechanism :: mechanism())
-> boolean()
).
is_disabled(Mechanism) ->
Disabled = ejabberd_config:get_option(
disable_sasl_mechanisms,
fun(V) when is_list(V) ->
lists:map(fun(M) -> str:to_upper(M) end, V);
(V) ->
[str:to_upper(V)]
end, []),
lists:member(Mechanism, Disabled).