mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Support also SASL PLAIN auth messages described in RFC4616 (EJAB-1132)
SVN Revision: 2841
This commit is contained in:
parent
3da20486c1
commit
6f3aeead07
@ -70,7 +70,7 @@ mech_new(_Host, _GetPassword, CheckPassword, _CheckPasswordDigest) ->
|
|||||||
%% Reason = term()
|
%% Reason = term()
|
||||||
|
|
||||||
mech_step(State, ClientIn) ->
|
mech_step(State, ClientIn) ->
|
||||||
case parse(ClientIn) of
|
case prepare(ClientIn) of
|
||||||
[AuthzId, User, Password] ->
|
[AuthzId, User, Password] ->
|
||||||
case (State#state.check_password)(User, Password) of
|
case (State#state.check_password)(User, Password) of
|
||||||
{true, AuthModule} ->
|
{true, AuthModule} ->
|
||||||
@ -83,6 +83,24 @@ mech_step(State, ClientIn) ->
|
|||||||
{error, 'bad-protocol'}
|
{error, 'bad-protocol'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
prepare(ClientIn) ->
|
||||||
|
case parse(ClientIn) of
|
||||||
|
[[], UserMaybeDomain, Password] ->
|
||||||
|
case parse_domain(UserMaybeDomain) of
|
||||||
|
%% <NUL>login@domain<NUL>pwd
|
||||||
|
[User, Domain] ->
|
||||||
|
[UserMaybeDomain, User, Password];
|
||||||
|
%% <NUL>login<NUL>pwd
|
||||||
|
[User] ->
|
||||||
|
["", User, Password]
|
||||||
|
end;
|
||||||
|
%% login@domain<NUL>login<NUL>pwd
|
||||||
|
[AuthzId, User, Password] ->
|
||||||
|
[AuthzId, User, Password];
|
||||||
|
_ ->
|
||||||
|
error
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
%% @hidden
|
%% @hidden
|
||||||
|
|
||||||
@ -101,5 +119,12 @@ parse1([], S, T) ->
|
|||||||
lists:reverse([lists:reverse(S) | T]).
|
lists:reverse([lists:reverse(S) | T]).
|
||||||
|
|
||||||
|
|
||||||
|
parse_domain(S) ->
|
||||||
|
parse_domain1(S, "", []).
|
||||||
|
|
||||||
|
parse_domain1([$@ | Cs], S, T) ->
|
||||||
|
parse_domain1(Cs, "", [lists:reverse(S) | T]);
|
||||||
|
parse_domain1([C | Cs], S, T) ->
|
||||||
|
parse_domain1(Cs, [C | S], T);
|
||||||
|
parse_domain1([], S, T) ->
|
||||||
|
lists:reverse([lists:reverse(S) | T]).
|
||||||
|
Loading…
Reference in New Issue
Block a user