mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
SASL errors are now atoms, not strings anymore.
SVN Revision: 1420
This commit is contained in:
parent
13b78b1ad2
commit
1a687a4f1a
@ -1,3 +1,9 @@
|
|||||||
|
2008-07-08 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
||||||
|
|
||||||
|
* src/cyrsasl.erl, src/cyrsasl_anonymous.erl, src/cyrsasl_digest.erl,
|
||||||
|
src/cyrsasl_plain.erl, src/ejabberd_c2s.erl: Errors are now atoms, not
|
||||||
|
strings anymore.
|
||||||
|
|
||||||
2008-07-01 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
2008-07-01 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
||||||
|
|
||||||
* src/ejabberd_sm.erl: Convert to exmpp.
|
* src/ejabberd_sm.erl: Convert to exmpp.
|
||||||
|
@ -86,14 +86,14 @@ register_mechanism(Mechanism, Module, RequirePlainPassword) ->
|
|||||||
%% end.
|
%% end.
|
||||||
|
|
||||||
check_credentials(_State, Props) ->
|
check_credentials(_State, Props) ->
|
||||||
User = xml:get_attr_s(username, Props),
|
case proplists:get_value(username, Props) of
|
||||||
case jlib:nodeprep(User) of
|
undefined ->
|
||||||
error ->
|
{error, 'not-authorized'};
|
||||||
{error, "not-authorized"};
|
User ->
|
||||||
"" ->
|
case exmpp_stringprep:is_node(User) of
|
||||||
{error, "not-authorized"};
|
false -> {error, 'not-authorized'};
|
||||||
_LUser ->
|
true -> ok
|
||||||
ok
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
listmech(Host) ->
|
listmech(Host) ->
|
||||||
@ -133,10 +133,10 @@ server_start(State, Mech, ClientIn) ->
|
|||||||
mech_state = MechState},
|
mech_state = MechState},
|
||||||
ClientIn);
|
ClientIn);
|
||||||
_ ->
|
_ ->
|
||||||
{error, "no-mechanism"}
|
{error, 'no-mechanism'}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
{error, "no-mechanism"}
|
{error, 'no-mechanism'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
server_step(State, ClientIn) ->
|
server_step(State, ClientIn) ->
|
||||||
|
@ -50,7 +50,7 @@ mech_step(State, _ClientIn) ->
|
|||||||
|
|
||||||
%% Checks that the username is available
|
%% Checks that the username is available
|
||||||
case ejabberd_auth:is_user_exists(User, Server) of
|
case ejabberd_auth:is_user_exists(User, Server) of
|
||||||
true -> {error, "not-authorized"};
|
true -> {error, 'not-authorized'};
|
||||||
false -> {ok, [{username, User},
|
false -> {ok, [{username, User},
|
||||||
{auth_module, ejabberd_auth_anonymous}]}
|
{auth_module, ejabberd_auth_anonymous}]}
|
||||||
end.
|
end.
|
||||||
|
@ -39,13 +39,13 @@ mech_step(#state{step = 1, nonce = Nonce} = State, _) ->
|
|||||||
mech_step(#state{step = 3, nonce = Nonce} = State, ClientIn) ->
|
mech_step(#state{step = 3, nonce = Nonce} = State, ClientIn) ->
|
||||||
case parse(ClientIn) of
|
case parse(ClientIn) of
|
||||||
bad ->
|
bad ->
|
||||||
{error, "bad-protocol"};
|
{error, 'bad-protocol'};
|
||||||
KeyVals ->
|
KeyVals ->
|
||||||
UserName = xml:get_attr_s("username", KeyVals),
|
UserName = xml:get_attr_s("username", KeyVals),
|
||||||
AuthzId = xml:get_attr_s("authzid", KeyVals),
|
AuthzId = xml:get_attr_s("authzid", KeyVals),
|
||||||
case (State#state.get_password)(UserName) of
|
case (State#state.get_password)(UserName) of
|
||||||
{false, _} ->
|
{false, _} ->
|
||||||
{error, "not-authorized", UserName};
|
{error, 'not-authorized', UserName};
|
||||||
{Passwd, AuthModule} ->
|
{Passwd, AuthModule} ->
|
||||||
Response = response(KeyVals, UserName, Passwd,
|
Response = response(KeyVals, UserName, Passwd,
|
||||||
Nonce, AuthzId, "AUTHENTICATE"),
|
Nonce, AuthzId, "AUTHENTICATE"),
|
||||||
@ -61,7 +61,7 @@ mech_step(#state{step = 3, nonce = Nonce} = State, ClientIn) ->
|
|||||||
username = UserName,
|
username = UserName,
|
||||||
authzid = AuthzId}};
|
authzid = AuthzId}};
|
||||||
_ ->
|
_ ->
|
||||||
{error, "not-authorized", UserName}
|
{error, 'not-authorized', UserName}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@ -73,7 +73,7 @@ mech_step(#state{step = 5,
|
|||||||
{auth_module, AuthModule}]};
|
{auth_module, AuthModule}]};
|
||||||
mech_step(A, B) ->
|
mech_step(A, B) ->
|
||||||
?DEBUG("SASL DIGEST: A ~p B ~p", [A,B]),
|
?DEBUG("SASL DIGEST: A ~p B ~p", [A,B]),
|
||||||
{error, "bad-protocol"}.
|
{error, 'bad-protocol'}.
|
||||||
|
|
||||||
|
|
||||||
parse(S) ->
|
parse(S) ->
|
||||||
|
@ -51,10 +51,10 @@ mech_step(State, ClientIn) ->
|
|||||||
{ok, [{username, User}, {authzid, AuthzId},
|
{ok, [{username, User}, {authzid, AuthzId},
|
||||||
{auth_module, AuthModule}]};
|
{auth_module, AuthModule}]};
|
||||||
_ ->
|
_ ->
|
||||||
{error, "not-authorized", User}
|
{error, 'not-authorized', User}
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
{error, "bad-protocol"}
|
{error, 'bad-protocol'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
@ -515,15 +515,13 @@ wait_for_feature_request({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
|
|||||||
"(~w) Failed authentication for ~s@~s",
|
"(~w) Failed authentication for ~s@~s",
|
||||||
[StateData#state.socket,
|
[StateData#state.socket,
|
||||||
Username, StateData#state.server]),
|
Username, StateData#state.server]),
|
||||||
% XXX OLD FORMAT: list_to_atom(Error).
|
|
||||||
send_element(StateData,
|
send_element(StateData,
|
||||||
exmpp_server_sasl:failure(list_to_atom(Error))),
|
exmpp_server_sasl:failure(Error)),
|
||||||
{next_state, wait_for_feature_request, StateData,
|
{next_state, wait_for_feature_request, StateData,
|
||||||
?C2S_OPEN_TIMEOUT};
|
?C2S_OPEN_TIMEOUT};
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
% XXX OLD FORMAT: list_to_atom(Error).
|
|
||||||
send_element(StateData,
|
send_element(StateData,
|
||||||
exmpp_server_sasl:failure(list_to_atom(Error))),
|
exmpp_server_sasl:failure(Error)),
|
||||||
fsm_next_state(wait_for_feature_request, StateData)
|
fsm_next_state(wait_for_feature_request, StateData)
|
||||||
end;
|
end;
|
||||||
{?NS_TLS, 'starttls'} when TLS == true,
|
{?NS_TLS, 'starttls'} when TLS == true,
|
||||||
@ -631,14 +629,12 @@ wait_for_sasl_response({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
|
|||||||
"(~w) Failed authentication for ~s@~s",
|
"(~w) Failed authentication for ~s@~s",
|
||||||
[StateData#state.socket,
|
[StateData#state.socket,
|
||||||
Username, StateData#state.server]),
|
Username, StateData#state.server]),
|
||||||
% XXX OLD FORMAT: list_to_atom(Error).
|
|
||||||
send_element(StateData,
|
send_element(StateData,
|
||||||
exmpp_server_sasl:failure(list_to_atom(Error))),
|
exmpp_server_sasl:failure(Error)),
|
||||||
fsm_next_state(wait_for_feature_request, StateData);
|
fsm_next_state(wait_for_feature_request, StateData);
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
% XXX OLD FORMAT: list_to_atom(Error).
|
|
||||||
send_element(StateData,
|
send_element(StateData,
|
||||||
exmpp_server_sasl:failure(list_to_atom(Error))),
|
exmpp_server_sasl:failure(Error)),
|
||||||
fsm_next_state(wait_for_feature_request, StateData)
|
fsm_next_state(wait_for_feature_request, StateData)
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
|
Loading…
Reference in New Issue
Block a user