summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sebastien Pedron <jean-sebastien@rabbitmq.com>2014-12-02 17:55:23 +0100
committerJean-Sebastien Pedron <jean-sebastien@rabbitmq.com>2014-12-02 17:55:23 +0100
commite74bd8fe71260fe669793bcdad245591a61c56ab (patch)
tree0436a6d840749b7d30d538cd478ece4150f280f9
parent6aa27b4694b043423d2d992602643420f955f91d (diff)
downloadrabbitmq-server-e74bd8fe71260fe669793bcdad245591a61c56ab.tar.gz
Pass "extra properties" to notify_auth_result/{3,4} instead of a message
This avoids to passs an empty message in the case of successful authentication.
-rw-r--r--src/rabbit_direct.erl12
-rw-r--r--src/rabbit_reader.erl15
2 files changed, 12 insertions, 15 deletions
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl
index ddd8d4e5..34eff61f 100644
--- a/src/rabbit_direct.erl
+++ b/src/rabbit_direct.erl
@@ -85,26 +85,24 @@ connect0(AuthFun, VHost, Protocol, Pid, Infos) ->
true -> case AuthFun() of
{ok, User = #user{username = Username}} ->
notify_auth_result(Username,
- user_authentication_success, "", []),
+ user_authentication_success, []),
connect1(User, VHost, Protocol, Pid, Infos);
{refused, Username, Msg, Args} ->
notify_auth_result(Username,
- user_authentication_failure, Msg, Args),
+ user_authentication_failure,
+ [{error, rabbit_misc:format(Msg, Args)}]),
{error, {auth_failure, "Refused"}}
end;
false -> {error, broker_not_found_on_node}
end.
-notify_auth_result(Username, AuthResult, Msg, Args) ->
+notify_auth_result(Username, AuthResult, ExtraProps) ->
EventProps0 = [{connection_type, direct}],
EventProps1 = case Username of
none -> [{name, ''} | EventProps0];
_ -> [{name, Username} | EventProps0]
end,
- EventProps = case Msg of
- "" -> EventProps1;
- _ -> [{error, rabbit_misc:format(Msg, Args)} | EventProps1]
- end,
+ EventProps = EventProps1 ++ ExtraProps,
rabbit_event:notify(AuthResult, EventProps).
connect1(User, VHost, Protocol, Pid, Infos) ->
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 1ec8a150..968e6a4d 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -1058,7 +1058,8 @@ auth_phase(Response,
auth_fail(Username, Msg, Args, Name, State);
{protocol_error, Msg, Args} ->
notify_auth_result(none, user_authentication_failure,
- Msg, Args, State),
+ [{error, rabbit_misc:format(Msg, Args)}],
+ State),
rabbit_misc:protocol_error(syntax_error, Msg, Args);
{challenge, Challenge, AuthState1} ->
Secure = #'connection.secure'{challenge = Challenge},
@@ -1069,7 +1070,7 @@ auth_phase(Response,
case rabbit_access_control:check_user_loopback(Username, Sock) of
ok ->
notify_auth_result(Username, user_authentication_success,
- "", [], State);
+ [], State);
not_allowed ->
auth_fail(Username, "user '~s' can only connect via "
"localhost", [Username], Name, State)
@@ -1091,7 +1092,8 @@ auth_phase(Response,
auth_fail(Username, Msg, Args, AuthName,
State = #v1{connection = #connection{protocol = Protocol,
capabilities = Capabilities}}) ->
- notify_auth_result(Username, user_authentication_failure, Msg, Args, State),
+ notify_auth_result(Username, user_authentication_failure,
+ [{error, rabbit_misc:format(Msg, Args)}], State),
AmqpError = rabbit_misc:amqp_error(
access_refused, "~s login refused: ~s",
[AuthName, io_lib:format(Msg, Args)], none),
@@ -1110,7 +1112,7 @@ auth_fail(Username, Msg, Args, AuthName,
end,
rabbit_misc:protocol_error(AmqpError).
-notify_auth_result(Username, AuthResult, Msg, Args, State) ->
+notify_auth_result(Username, AuthResult, ExtraProps, State) ->
EventProps0 = [{connection_type, network}],
EventProps1 = EventProps0 ++ [
case Item of
@@ -1129,10 +1131,7 @@ notify_auth_result(Username, AuthResult, Msg, Args, State) ->
none -> [{name, ''} | EventProps2];
_ -> [{name, Username} | EventProps2]
end,
- EventProps = case Msg of
- "" -> EventProps3;
- _ -> [{error, rabbit_misc:format(Msg, Args)} | EventProps3]
- end,
+ EventProps = EventProps3 ++ ExtraProps,
rabbit_event:notify(AuthResult, EventProps).
%%--------------------------------------------------------------------------