diff options
author | Jean-Sebastien Pedron <jean-sebastien@rabbitmq.com> | 2014-12-02 17:55:23 +0100 |
---|---|---|
committer | Jean-Sebastien Pedron <jean-sebastien@rabbitmq.com> | 2014-12-02 17:55:23 +0100 |
commit | e74bd8fe71260fe669793bcdad245591a61c56ab (patch) | |
tree | 0436a6d840749b7d30d538cd478ece4150f280f9 /src/rabbit_reader.erl | |
parent | 6aa27b4694b043423d2d992602643420f955f91d (diff) | |
download | rabbitmq-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.
Diffstat (limited to 'src/rabbit_reader.erl')
-rw-r--r-- | src/rabbit_reader.erl | 15 |
1 files changed, 7 insertions, 8 deletions
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). %%-------------------------------------------------------------------------- |