summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-09-11 13:10:01 +0100
committerSimon MacMullen <simon@rabbitmq.com>2012-09-11 13:10:01 +0100
commit94b75a4ac2adc4a003db8b6dc688d70369bb803f (patch)
tree5942e4b00b67750b48ad6c002fb48e67a54e7eb0
parentd22b4b01e69a75a073c7a67d6a3c92fba92e2075 (diff)
downloadrabbitmq-server-94b75a4ac2adc4a003db8b6dc688d70369bb803f.tar.gz
Allow direct client users to provide a complete #user{} record rather than looking it up for them.
-rw-r--r--src/rabbit_direct.erl28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl
index c87b1dc1..a669a2b3 100644
--- a/src/rabbit_direct.erl
+++ b/src/rabbit_direct.erl
@@ -31,8 +31,8 @@
-spec(force_event_refresh/0 :: () -> 'ok').
-spec(list/0 :: () -> [pid()]).
-spec(list_local/0 :: () -> [pid()]).
--spec(connect/5 :: (rabbit_types:username(), rabbit_types:vhost(),
- rabbit_types:protocol(), pid(),
+-spec(connect/5 :: ((rabbit_types:username() | rabbit_types:user()),
+ rabbit_types:vhost(), rabbit_types:protocol(), pid(),
rabbit_event:event_props()) ->
{'ok', {rabbit_types:user(),
rabbit_framing:amqp_table()}}).
@@ -64,22 +64,22 @@ list() ->
%%----------------------------------------------------------------------------
+connect(User = #user{}, VHost, Protocol, Pid, Infos) ->
+ try rabbit_access_control:check_vhost_access(User, VHost) of
+ ok -> ok = pg_local:join(rabbit_direct, Pid),
+ rabbit_event:notify(connection_created, Infos),
+ {ok, {User, rabbit_reader:server_properties(Protocol)}}
+ catch
+ exit:#amqp_error{name = access_refused} ->
+ {error, access_refused}
+ end;
+
connect(Username, VHost, Protocol, Pid, Infos) ->
case rabbit:is_running() of
true ->
case rabbit_access_control:check_user_login(Username, []) of
- {ok, User} ->
- try rabbit_access_control:check_vhost_access(User, VHost) of
- ok -> ok = pg_local:join(rabbit_direct, Pid),
- rabbit_event:notify(connection_created, Infos),
- {ok, {User,
- rabbit_reader:server_properties(Protocol)}}
- catch
- exit:#amqp_error{name = access_refused} ->
- {error, access_refused}
- end;
- {refused, _Msg, _Args} ->
- {error, auth_failure}
+ {ok, User} -> connect(User, VHost, Protocol, Pid, Infos);
+ {refused, _M, _A} -> {error, auth_failure}
end;
false ->
{error, broker_not_found_on_node}