diff options
author | Badlop <badlop@process-one.net> | 2009-12-29 18:44:17 +0000 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2009-12-29 18:44:17 +0000 |
commit | f0863e1dfe5e53dd4d4712133dab812d04a1d019 (patch) | |
tree | 4799e90991c07155f6e4421b79327b434f917a97 | |
parent | Disable code of recent commit because some clients can't handle it (EJAB-1058) (diff) |
Support also SASL PLAIN auth messages described in RFC4616 (EJAB-1132)
SVN Revision: 2839
-rw-r--r-- | src/cyrsasl_plain.erl | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/cyrsasl_plain.erl b/src/cyrsasl_plain.erl index 4e69b06ba..696e303e5 100644 --- a/src/cyrsasl_plain.erl +++ b/src/cyrsasl_plain.erl @@ -44,7 +44,7 @@ mech_new(_Host, _GetPassword, CheckPassword, _CheckPasswordDigest) -> {ok, #state{check_password = CheckPassword}}. mech_step(State, ClientIn) -> - case parse(ClientIn) of + case prepare(ClientIn) of [AuthzId, User, Password] -> case (State#state.check_password)(User, Password) of {true, AuthModule} -> @@ -57,6 +57,24 @@ mech_step(State, ClientIn) -> {error, "bad-protocol"} 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. + parse(S) -> parse1(S, "", []). @@ -71,5 +89,12 @@ parse1([], 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]). |